conrad-digi-35-cpu: Add missing Makefile.am, minor cosmetics.

This commit is contained in:
Uwe Hermann 2014-02-12 15:13:41 +01:00
parent c6a2843a58
commit 0294a409b8
4 changed files with 69 additions and 34 deletions

View File

@ -0,0 +1,33 @@
##
## This file is part of the libsigrok project.
##
## Copyright (C) 2014 Matthias Heidbrink <m-sigrok@heidbrink.biz>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
##
if HW_CONRAD_DIGI_35_CPU
# Local lib, this is NOT meant to be installed!
noinst_LTLIBRARIES = libsigrok_hw_conrad_digi_35_cpu.la
libsigrok_hw_conrad_digi_35_cpu_la_SOURCES = \
api.c \
protocol.c \
protocol.h
libsigrok_hw_conrad_digi_35_cpu_la_CFLAGS = \
-I$(top_srcdir)
endif

View File

@ -24,6 +24,8 @@
#include "protocol.h"
#define SERIALCOMM "9600/8n1"
static const int32_t hwopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
@ -33,14 +35,10 @@ static const int32_t hwcaps[] = {
SR_CONF_POWER_SUPPLY,
SR_CONF_OUTPUT_VOLTAGE,
SR_CONF_OUTPUT_CURRENT,
/* There is no SR_CONF_OUTPUT_ENABLED; cannot know or set status remotely. */
/* There's no SR_CONF_OUTPUT_ENABLED; can't know/set status remotely. */
SR_CONF_OVER_CURRENT_PROTECTION,
};
#define SERIALCOMM "9600/8n1"
SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
static struct sr_dev_driver *di = &conrad_digi_35_cpu_driver_info;
@ -80,9 +78,11 @@ static GSList *scan(GSList *options)
if (!serialcomm)
serialcomm = SERIALCOMM;
/* We cannot scan for this device because it is write-only.
/*
* We cannot scan for this device because it is write-only.
* So just check that the port parameters are valid and assume that
* the device is there. */
* the device is there.
*/
if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
return NULL;
@ -93,7 +93,7 @@ static GSList *scan(GSList *options)
serial_flush(serial);
serial_close(serial);
sr_spew("Conrad DIGI 35 CPU assumed at %s", conn);
sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
if (!(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, "Conrad", "DIGI 35 CPU", "")))
return NULL;
@ -123,9 +123,7 @@ static int dev_clear(void)
static int cleanup(void)
{
dev_clear();
return SR_OK;
return dev_clear();
}
static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
@ -196,8 +194,7 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
return ret;
}
static int dev_acquisition_start_dummy(const struct sr_dev_inst *sdi,
void *cb_data)
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
{
(void)cb_data;
@ -207,7 +204,7 @@ static int dev_acquisition_start_dummy(const struct sr_dev_inst *sdi,
return SR_OK;
}
static int dev_acquisition_stop_dummy(struct sr_dev_inst *sdi, void *cb_data)
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
{
(void)cb_data;
@ -231,7 +228,7 @@ SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
.config_list = config_list,
.dev_open = std_serial_dev_open,
.dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start_dummy,
.dev_acquisition_stop = dev_acquisition_stop_dummy,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
.priv = NULL,
};

View File

@ -17,24 +17,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
* <em>Conrad DIGI 35 CPU</em> power supply driver
* @internal
/**
* @file
* <em>Conrad DIGI 35 CPU</em> power supply driver
* @internal
*/
#include "protocol.h"
#include <errno.h>
#include <string.h>
/** Send command with parameter.
/**
* Send command with parameter.
*
* @param[in] cmd Command
* @param[in] param Parameter (0..999, depending on command).
* @param[in] cmd Command
* @param[in] param Parameter (0..999, depending on command).
*
* @retval SR_OK Success
* @retval SR_ERR_ARG Invalid argument.
* @retval SR_ERR Error.
* @retval SR_OK Success.
* @retval SR_ERR_ARG Invalid argument.
* @retval SR_ERR Error.
*/
SR_PRIV int send_msg1(const struct sr_dev_inst *sdi, char cmd, int param)
{
@ -53,7 +52,12 @@ SR_PRIV int send_msg1(const struct sr_dev_inst *sdi, char cmd, int param)
sr_err("Write error for cmd=%c: %d %s", cmd, errno, strerror(errno));
return SR_ERR;
}
g_usleep(50000); /* Wait 50 ms to ensure that the device does not swallow following commands. */
/*
* Wait 50ms to ensure that the device does not swallow any of the
* following commands.
*/
g_usleep(50000);
return SR_OK;
}

View File

@ -17,21 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file
* <em>Conrad DIGI 35 CPU</em> power supply driver
* @internal
/**
* @file
* <em>Conrad DIGI 35 CPU</em> power supply driver
* @internal
*/
#ifndef LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
/* Message logging helpers with subsystem-specific prefix string. */
#define LOG_PREFIX "conrad-digi-35-cpu"
SR_PRIV int send_msg1(const struct sr_dev_inst *sdi, char cmd, int param);