--- /dev/null
+##
+## 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
#include "protocol.h"
+#define SERIALCOMM "9600/8n1"
+
static const int32_t hwopts[] = {
SR_CONF_CONN,
SR_CONF_SERIALCOMM,
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;
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;
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;
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,
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;
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;
.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,
};
* 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)
{
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;
}
* 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);