]> sigrok.org Git - libsigrok.git/commitdiff
conrad-digi-35-cpu: Initial driver framework.
authorMatthias Heidbrink <redacted>
Wed, 5 Feb 2014 18:50:46 +0000 (19:50 +0100)
committerUwe Hermann <redacted>
Wed, 12 Feb 2014 14:10:06 +0000 (15:10 +0100)
configure.ac
hardware/Makefile.am
hardware/conrad-digi-35-cpu/api.c [new file with mode: 0644]
hardware/conrad-digi-35-cpu/protocol.c [new file with mode: 0644]
hardware/conrad-digi-35-cpu/protocol.h [new file with mode: 0644]
hwdriver.c

index 98ce84b82dd56fa84bea548ef7e19c81e89fd800..957b350c42c0437e3faf140144aadd421aaaf3ed 100644 (file)
@@ -134,6 +134,11 @@ AC_ARG_ENABLE(colead-slm, AC_HELP_STRING([--enable-colead-slm],
        [HW_COLEAD_SLM="$enableval"],
        [HW_COLEAD_SLM=$HW_ENABLED_DEFAULT])
 
+AC_ARG_ENABLE(conrad-digi-35-cpu, AC_HELP_STRING([--enable-conrad-digi-35-cpu],
+       [enable Conrad DIGI 35 CPU support [default=yes]]),
+       [HW_CONRAD_DIGI_35_CPU="$enableval"],
+       [HW_CONRAD_DIGI_35_CPU=$HW_ENABLED_DEFAULT])
+
 AC_ARG_ENABLE(demo, AC_HELP_STRING([--enable-demo],
        [enable demo driver support [default=yes]]),
        [HW_DEMO="$enableval"],
@@ -274,10 +279,10 @@ AC_SEARCH_LIBS([pow], [m])
 # RPC is only needed for VXI support.
 AC_MSG_CHECKING([for RPC support])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <rpc/rpc.h>],
-                                [CLIENT *rpc_test(void)],
-                                [{ return clnt_create("", 0, 0, ""); }])],
-               [AC_MSG_RESULT([yes]); have_rpc=1],
-               [AC_MSG_RESULT([no]);  have_rpc=0])
+                               [CLIENT *rpc_test(void)],
+                               [{ return clnt_create("", 0, 0, ""); }])],
+              [AC_MSG_RESULT([yes]); have_rpc=1],
+              [AC_MSG_RESULT([no]);  have_rpc=0])
 # Define HAVE_RPC in config.h if we found RPC support.
 AC_DEFINE_UNQUOTED(HAVE_RPC, [$have_rpc], [Specifies whether we have RPC support.])
 # VXI support is only compiled if RPC support was found.
@@ -302,8 +307,8 @@ PKG_CHECK_MODULES([libserialport], [libserialport >= 0.1.0],
        SR_PKGLIBS="$SR_PKGLIBS libserialport"],
        [have_libserialport="no"; HW_AGILENT_DMM="no"; HW_APPA_55II="no";
        HW_ATTEN_PPS3XXX="no"; HW_BRYMEN_DMM="no"; HW_CEM_DT_885X="no";
-       HW_CENTER_3XX="no"; HW_COLEAD_SLM="no"; HW_FLUKE_DMM="no";
-       HW_GMC_MH_1X_2X="no"; HW_HAMEG_HMO="no"; HW_LINK_MSO19="no";
+       HW_CENTER_3XX="no"; HW_COLEAD_SLM="no"; HW_CONRAD_DIGI_35_CPU="no";
+       HW_FLUKE_DMM="no"; HW_GMC_MH_1X_2X="no"; HW_HAMEG_HMO="no"; HW_LINK_MSO19="no";
        HW_MIC_985XX="no"; HW_NORMA_DMM="no"; HW_OLS="no";
        HW_SERIAL_DMM="no"; HW_TELEINFO="no"; HW_TONDAJ_SL_814="no"])
 
@@ -450,6 +455,11 @@ if test "x$HW_COLEAD_SLM" = "xyes"; then
        AC_DEFINE(HAVE_HW_COLEAD_SLM, 1, [Colead SLM support])
 fi
 
+AM_CONDITIONAL(HW_CONRAD_DIGI_35_CPU, test x$HW_CONRAD_DIGI_35_CPU = xyes)
+if test "x$HW_CONRAD_DIGI_35_CPU" = "xyes"; then
+       AC_DEFINE(HAVE_HW_CONRAD_DIGI_35_CPU, 1, [Conrad DIGI 35 CPU support])
+fi
+
 AM_CONDITIONAL(HW_DEMO, test x$HW_DEMO = xyes)
 if test "x$HW_DEMO" = "xyes"; then
        AC_DEFINE(HAVE_HW_DEMO, 1, [Demo driver support])
@@ -602,6 +612,7 @@ AC_CONFIG_FILES([Makefile version.h hardware/Makefile
                 hardware/chronovu-la8/Makefile
                 hardware/colead-slm/Makefile
                 hardware/common/Makefile
+                hardware/conrad-digi-35-cpu/Makefile
                 hardware/gmc-mh-1x-2x/Makefile
                 hardware/hameg-hmo/Makefile
                 hardware/ikalogic-scanalogic2/Makefile
@@ -671,6 +682,7 @@ echo "  - cem-dt-885x..................... $HW_CEM_DT_885X"
 echo "  - center-3xx...................... $HW_CENTER_3XX"
 echo "  - chronovu-la8.................... $HW_CHRONOVU_LA8"
 echo "  - colead-slm...................... $HW_COLEAD_SLM"
+echo "  - conrad-digi-35-cpu.............. $HW_CONRAD_DIGI_35_CPU"
 echo "  - demo............................ $HW_DEMO"
 echo "  - fluke-dmm....................... $HW_FLUKE_DMM"
 echo "  - fx2lafw......................... $HW_FX2LAFW"
index 617f620496c844719c375778f5c844f6ee69fb60..9ad8477994c2852b82b75d5d24fada25529dde7d 100644 (file)
@@ -30,6 +30,7 @@ SUBDIRS = \
        chronovu-la8 \
        colead-slm \
        common \
+       conrad-digi-35-cpu \
        demo \
        fluke-dmm \
        fx2lafw \
@@ -102,6 +103,10 @@ if HW_COLEAD_SLM
 libsigrokhardware_la_LIBADD += colead-slm/libsigrok_hw_colead_slm.la
 endif
 
+if HW_CONRAD_DIGI_35_CPU
+libsigrokhardware_la_LIBADD += conrad-digi-35-cpu/libsigrok_hw_conrad_digi_35_cpu.la
+endif
+
 if HW_DEMO
 libsigrokhardware_la_LIBADD += demo/libsigrok_hw_demo.la
 endif
diff --git a/hardware/conrad-digi-35-cpu/api.c b/hardware/conrad-digi-35-cpu/api.c
new file mode 100644 (file)
index 0000000..8407b3a
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * 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/>.
+ */
+
+#include "protocol.h"
+
+SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
+static struct sr_dev_driver *di = &conrad_digi_35_cpu_driver_info;
+
+static int init(struct sr_context *sr_ctx)
+{
+       return std_init(sr_ctx, di, LOG_PREFIX);
+}
+
+static GSList *scan(GSList *options)
+{
+       struct drv_context *drvc;
+       GSList *devices;
+
+       (void)options;
+
+       devices = NULL;
+       drvc = di->priv;
+       drvc->instances = NULL;
+
+       /* TODO: scan for devices, either based on a SR_CONF_CONN option
+        * or on a USB scan. */
+
+       return devices;
+}
+
+static GSList *dev_list(void)
+{
+       return ((struct drv_context *)(di->priv))->instances;
+}
+
+static int dev_clear(void)
+{
+       return std_dev_clear(di, NULL);
+}
+
+static int dev_open(struct sr_dev_inst *sdi)
+{
+       (void)sdi;
+
+       /* TODO: get handle from sdi->conn and open it. */
+
+       sdi->status = SR_ST_ACTIVE;
+
+       return SR_OK;
+}
+
+static int dev_close(struct sr_dev_inst *sdi)
+{
+       (void)sdi;
+
+       /* TODO: get handle from sdi->conn and close it. */
+
+       sdi->status = SR_ST_INACTIVE;
+
+       return SR_OK;
+}
+
+static int cleanup(void)
+{
+       dev_clear();
+
+       /* TODO: free other driver resources, if any. */
+
+       return SR_OK;
+}
+
+static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+       (void)probe_group;
+
+       ret = SR_OK;
+       switch (key) {
+       /* TODO */
+       default:
+               return SR_ERR_NA;
+       }
+
+       return ret;
+}
+
+static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
+{
+       int ret;
+
+       (void)data;
+       (void)probe_group;
+
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
+       ret = SR_OK;
+       switch (key) {
+       /* TODO */
+       default:
+               ret = SR_ERR_NA;
+       }
+
+       return ret;
+}
+
+static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
+               const struct sr_probe_group *probe_group)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+       (void)probe_group;
+
+       ret = SR_OK;
+       switch (key) {
+       /* TODO */
+       default:
+               return SR_ERR_NA;
+       }
+
+       return ret;
+}
+
+static int dev_acquisition_start(const struct sr_dev_inst *sdi,
+                                   void *cb_data)
+{
+       (void)sdi;
+       (void)cb_data;
+
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
+       /* TODO: configure hardware, reset acquisition state, set up
+        * callbacks and send header packet. */
+
+       return SR_OK;
+}
+
+static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+{
+       (void)cb_data;
+
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
+       /* TODO: stop acquisition. */
+
+       return SR_OK;
+}
+
+SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info = {
+       .name = "conrad-digi-35-cpu",
+       .longname = "Conrad DIGI 35 CPU",
+       .api_version = 1,
+       .init = init,
+       .cleanup = cleanup,
+       .scan = scan,
+       .dev_list = dev_list,
+       .dev_clear = dev_clear,
+       .config_get = config_get,
+       .config_set = config_set,
+       .config_list = config_list,
+       .dev_open = dev_open,
+       .dev_close = dev_close,
+       .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
new file mode 100644 (file)
index 0000000..ce86688
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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/>.
+ */
+
+#include "protocol.h"
+
+SR_PRIV int conrad_digi_35_cpu_receive_data(int fd, int revents, void *cb_data)
+{
+       const struct sr_dev_inst *sdi;
+       struct dev_context *devc;
+
+       (void)fd;
+
+       if (!(sdi = cb_data))
+               return TRUE;
+
+       if (!(devc = sdi->priv))
+               return TRUE;
+
+       if (revents == G_IO_IN) {
+               /* TODO */
+       }
+
+       return TRUE;
+}
diff --git a/hardware/conrad-digi-35-cpu/protocol.h b/hardware/conrad-digi-35-cpu/protocol.h
new file mode 100644 (file)
index 0000000..c363d9b
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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/>.
+ */
+
+#ifndef LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
+#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H
+
+#include <stdint.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"
+
+/** Private, per-device-instance driver context. */
+struct dev_context {
+       /* Model-specific information */
+
+       /* Acquisition settings */
+
+       /* Operational state */
+
+       /* Temporary state across callbacks */
+
+};
+
+SR_PRIV int conrad_digi_35_cpu_receive_data(int fd, int revents, void *cb_data);
+
+#endif
index 39b1e9a22698a8cda4150463eaef984f95aa4838..a3fe83d6e2be72f74c543b7c4b71812647940617 100644 (file)
@@ -143,6 +143,9 @@ extern SR_PRIV struct sr_dev_driver voltcraft_k204_driver_info;
 #ifdef HAVE_HW_COLEAD_SLM
 extern SR_PRIV struct sr_dev_driver colead_slm_driver_info;
 #endif
+#ifdef HAVE_HW_CONRAD_DIGI_35_CPU
+extern SR_PRIV struct sr_dev_driver conrad_digi_35_cpu_driver_info;
+#endif
 #ifdef HAVE_HW_DEMO
 extern SR_PRIV struct sr_dev_driver demo_driver_info;
 #endif
@@ -293,6 +296,9 @@ static struct sr_dev_driver *drivers_list[] = {
 #ifdef HAVE_HW_COLEAD_SLM
        &colead_slm_driver_info,
 #endif
+#ifdef HAVE_HW_CONRAD_DIGI_35_CPU
+       &conrad_digi_35_cpu_driver_info,
+#endif
 #ifdef HAVE_HW_DEMO
        &demo_driver_info,
 #endif