]> sigrok.org Git - libsigrok.git/commitdiff
testo: Initial driver skeleton.
authorBert Vermeulen <redacted>
Mon, 30 Jun 2014 23:34:29 +0000 (01:34 +0200)
committerBert Vermeulen <redacted>
Sat, 5 Jul 2014 19:56:46 +0000 (21:56 +0200)
Makefile.am
configure.ac
hardware/testo/api.c [new file with mode: 0644]
hardware/testo/protocol.c [new file with mode: 0644]
hardware/testo/protocol.h [new file with mode: 0644]
hwdriver.c

index dd6b7061938631670e27d87636d842c125a5a45a..a34985e7ef4bf166004aa095f055f72008852bea 100644 (file)
@@ -286,6 +286,12 @@ libsigrok_la_SOURCES += \
        hardware/teleinfo/protocol.c \
        hardware/teleinfo/api.c
 endif
+if HW_TESTO
+libsigrok_la_SOURCES += \
+       hardware/testo/protocol.h \
+       hardware/testo/protocol.c \
+       hardware/testo/api.c
+endif
 if HW_TONDAJ_SL_814
 libsigrok_la_SOURCES += \
        hardware/tondaj-sl-814/protocol.h \
index fc06fcf020282db6f918ab246a3c4bf7827c2c67..9c329369c61fa4099d9d3a42ef8a3429dc5eccc3 100644 (file)
@@ -240,6 +240,11 @@ AC_ARG_ENABLE(teleinfo, AC_HELP_STRING([--enable-teleinfo],
        [HW_TELEINFO="$enableval"],
        [HW_TELEINFO=$HW_ENABLED_DEFAULT])
 
+AC_ARG_ENABLE(testo, AC_HELP_STRING([--enable-testo],
+       [enable Testo support [default=yes]]),
+       [HW_TESTO="$enableval"],
+       [HW_TESTO=$HW_ENABLED_DEFAULT])
+
 AC_ARG_ENABLE(tondaj-sl-814, AC_HELP_STRING([--enable-tondaj-sl-814],
        [enable Tondaj SL-814 support [default=yes]]),
        [HW_TONDAJ_SL_814="$enableval"],
@@ -394,7 +399,7 @@ if test "x$have_libusb1_0" = "xno"; then
        HW_BRYMEN_BM86X="no"; HW_FX2LAFW="no";
        HW_HANTEK_DSO="no"; HW_IKALOGIC_SCANALOGIC2="no";
        HW_KECHENG_KC_330B="no"; HW_LASCAR_EL_USB="no";
-       HW_SYSCLK_LWLA="no"; HW_UNI_T_DMM="no";
+       HW_SYSCLK_LWLA="no"; HW_TESTO="no"; HW_UNI_T_DMM="no";
        HW_UNI_T_UT32X="no"; HW_VICTOR_DMM="no";
        HW_ZEROPLUS_LOGIC_CUBE="no"; HW_SALEAE_LOGIC16="no";
 else
@@ -601,6 +606,11 @@ if test "x$HW_TELEINFO" = "xyes"; then
        AC_DEFINE(HAVE_HW_TELEINFO, 1, [Teleinfo support])
 fi
 
+AM_CONDITIONAL(HW_TESTO, test x$HW_TESTO = xyes)
+if test "x$HW_TESTO" = "xyes"; then
+       AC_DEFINE(HAVE_HW_TESTO, 1, [Testo support])
+fi
+
 AM_CONDITIONAL(HW_TONDAJ_SL_814, test x$HW_TONDAJ_SL_814 = xyes)
 if test "x$HW_TONDAJ_SL_814" = "xyes"; then
        AC_DEFINE(HAVE_HW_TONDAJ_SL_814, 1, [Tondaj SL-814 support])
@@ -708,6 +718,7 @@ echo "  - saleae-logic16.................. $HW_SALEAE_LOGIC16"
 echo "  - serial-dmm...................... $HW_SERIAL_DMM"
 echo "  - sysclk-lwla..................... $HW_SYSCLK_LWLA"
 echo "  - teleinfo........................ $HW_TELEINFO"
+echo "  - testo........................... $HW_TESTO"
 echo "  - tondaj-sl-814................... $HW_TONDAJ_SL_814"
 echo "  - uni-t-dmm....................... $HW_UNI_T_DMM"
 echo "  - uni-t-ut32x..................... $HW_UNI_T_UT32X"
diff --git a/hardware/testo/api.c b/hardware/testo/api.c
new file mode 100644 (file)
index 0000000..bb529f8
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
+ *
+ * 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 testo_driver_info;
+static struct sr_dev_driver *di = &testo_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_channel_group *cg)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+       (void)cg;
+
+       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_channel_group *cg)
+{
+       int ret;
+
+       (void)data;
+       (void)cg;
+
+       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_channel_group *cg)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+       (void)cg;
+
+       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 testo_driver_info = {
+       .name = "testo",
+       .longname = "Testo",
+       .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/testo/protocol.c b/hardware/testo/protocol.c
new file mode 100644 (file)
index 0000000..eb6075d
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
+ *
+ * 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 testo_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/testo/protocol.h b/hardware/testo/protocol.h
new file mode 100644 (file)
index 0000000..dcabb9d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
+ *
+ * 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_TESTO_PROTOCOL_H
+#define LIBSIGROK_HARDWARE_TESTO_PROTOCOL_H
+
+#include <stdint.h>
+#include <glib.h>
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
+
+#define LOG_PREFIX "testo"
+
+/** Private, per-device-instance driver context. */
+struct dev_context {
+       /* Model-specific information */
+
+       /* Acquisition settings */
+
+       /* Operational state */
+
+       /* Temporary state across callbacks */
+
+};
+
+SR_PRIV int testo_receive_data(int fd, int revents, void *cb_data);
+
+#endif
index 6bfbfffe2f1923177b626427c81a6d27648bfdb5..3ac151a8eff154d5c89fbe1799c7a14a90d1e3b0 100644 (file)
@@ -28,6 +28,9 @@
 #include "libsigrok-internal.h"
 
 /** @cond PRIVATE */
+#ifdef HAVE_HW_TESTO
+extern SR_PRIV struct sr_dev_driver testo_driver_info;
+#endif
 #define LOG_PREFIX "hwdriver"
 /** @endcond */
 
@@ -202,6 +205,9 @@ extern SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info;
 #ifdef HAVE_HW_TELEINFO
 extern SR_PRIV struct sr_dev_driver teleinfo_driver_info;
 #endif
+#ifdef HAVE_HW_TESTO
+extern SR_PRIV struct sr_dev_driver testo_driver_info;
+#endif
 #ifdef HAVE_HW_TONDAJ_SL_814
 extern SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
 #endif
@@ -364,6 +370,9 @@ static struct sr_dev_driver *drivers_list[] = {
 #ifdef HAVE_HW_TELEINFO
        &teleinfo_driver_info,
 #endif
+#ifdef HAVE_HW_TESTO
+       &testo_driver_info,
+#endif
 #ifdef HAVE_HW_TONDAJ_SL_814
        &tondaj_sl_814_driver_info,
 #endif