From: Matthias Heidbrink Date: Wed, 5 Feb 2014 18:50:46 +0000 (+0100) Subject: conrad-digi-35-cpu: Initial driver framework. X-Git-Tag: libsigrok-0.3.0~141 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=823b4e5817af106e88ab4be2bdb999ac9d1ee50b;p=libsigrok.git conrad-digi-35-cpu: Initial driver framework. --- diff --git a/configure.ac b/configure.ac index 98ce84b8..957b350c 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ], - [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" diff --git a/hardware/Makefile.am b/hardware/Makefile.am index 617f6204..9ad84779 100644 --- a/hardware/Makefile.am +++ b/hardware/Makefile.am @@ -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 index 00000000..8407b3a0 --- /dev/null +++ b/hardware/conrad-digi-35-cpu/api.c @@ -0,0 +1,191 @@ +/* + * 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 . + */ + +#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 index 00000000..ce866880 --- /dev/null +++ b/hardware/conrad-digi-35-cpu/protocol.c @@ -0,0 +1,40 @@ +/* + * 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 . + */ + +#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 index 00000000..c363d9b7 --- /dev/null +++ b/hardware/conrad-digi-35-cpu/protocol.h @@ -0,0 +1,45 @@ +/* + * 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 . + */ + +#ifndef LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H +#define LIBSIGROK_HARDWARE_CONRAD_DIGI_35_CPU_PROTOCOL_H + +#include +#include +#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 diff --git a/hwdriver.c b/hwdriver.c index 39b1e9a2..a3fe83d6 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -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