From: Uwe Hermann Date: Wed, 12 Feb 2014 14:13:41 +0000 (+0100) Subject: conrad-digi-35-cpu: Add missing Makefile.am, minor cosmetics. X-Git-Tag: libsigrok-0.3.0~139 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0294a409b80f21c8197fa4533fd9819f8274a381;p=libsigrok.git conrad-digi-35-cpu: Add missing Makefile.am, minor cosmetics. --- diff --git a/hardware/conrad-digi-35-cpu/Makefile.am b/hardware/conrad-digi-35-cpu/Makefile.am new file mode 100644 index 00000000..6f86b687 --- /dev/null +++ b/hardware/conrad-digi-35-cpu/Makefile.am @@ -0,0 +1,33 @@ +## +## This file is part of the libsigrok project. +## +## Copyright (C) 2014 Matthias Heidbrink +## +## 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 . +## + +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 diff --git a/hardware/conrad-digi-35-cpu/api.c b/hardware/conrad-digi-35-cpu/api.c index 5aac3cff..0887de29 100644 --- a/hardware/conrad-digi-35-cpu/api.c +++ b/hardware/conrad-digi-35-cpu/api.c @@ -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, }; diff --git a/hardware/conrad-digi-35-cpu/protocol.c b/hardware/conrad-digi-35-cpu/protocol.c index 0937bf6d..7657b319 100644 --- a/hardware/conrad-digi-35-cpu/protocol.c +++ b/hardware/conrad-digi-35-cpu/protocol.c @@ -17,24 +17,23 @@ * along with this program. If not, see . */ -/** @file - * Conrad DIGI 35 CPU power supply driver - * @internal +/** + * @file + * Conrad DIGI 35 CPU power supply driver + * @internal */ #include "protocol.h" -#include -#include - -/** 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; } diff --git a/hardware/conrad-digi-35-cpu/protocol.h b/hardware/conrad-digi-35-cpu/protocol.h index 301a8026..fcde852e 100644 --- a/hardware/conrad-digi-35-cpu/protocol.h +++ b/hardware/conrad-digi-35-cpu/protocol.h @@ -17,21 +17,22 @@ * along with this program. If not, see . */ -/** @file - * Conrad DIGI 35 CPU power supply driver - * @internal +/** + * @file + * Conrad DIGI 35 CPU power supply driver + * @internal */ #ifndef LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H #define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H #include +#include +#include #include - #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);