]> sigrok.org Git - libsigrok.git/commitdiff
uni-t-ut32x: Initial driver skeleton.
authorBert Vermeulen <redacted>
Thu, 8 Aug 2013 22:29:04 +0000 (00:29 +0200)
committerBert Vermeulen <redacted>
Sun, 11 Aug 2013 08:46:36 +0000 (10:46 +0200)
configure.ac
hardware/Makefile.am
hardware/uni-t-ut32x/Makefile.am [new file with mode: 0644]
hardware/uni-t-ut32x/api.c [new file with mode: 0644]
hardware/uni-t-ut32x/protocol.c [new file with mode: 0644]
hardware/uni-t-ut32x/protocol.h [new file with mode: 0644]
hwdriver.c

index 3ac06e7768186a6ce0ba181fb279bad9f5e55922..8f8aa0dafa67690425ed644dee3acd77d1ae81fe 100644 (file)
@@ -199,6 +199,11 @@ AC_ARG_ENABLE(uni-t-dmm, AC_HELP_STRING([--enable-uni-t-dmm],
        [HW_UNI_T_DMM="$enableval"],
        [HW_UNI_T_DMM=$HW_ENABLED_DEFAULT])
 
+AC_ARG_ENABLE(uni-t-ut32x, AC_HELP_STRING([--enable-uni-t-ut32x],
+       [enable UNI-T UT32x support [default=yes]]),
+       [HW_UNI_T_UT32X="$enableval"],
+       [HW_UNI_T_UT32X=yes])
+
 AC_ARG_ENABLE(victor-dmm, AC_HELP_STRING([--enable-victor-dmm],
        [enable victor-dmm support [default=yes]]),
        [HW_VICTOR_DMM="$enableval"],
@@ -422,6 +427,11 @@ if test "x$HW_UNI_T_DMM" = "xyes"; then
        AC_DEFINE(HAVE_HW_UNI_T_DMM, 1, [UNI-T DMM support])
 fi
 
+AM_CONDITIONAL(HW_UNI_T_UT32X, test x$HW_UNI_T_UT32X = xyes)
+if test "x$HW_UNI_T_UT32X" = "xyes"; then
+       AC_DEFINE(HAVE_HW_UNI_T_UT32X, 1, [UNI-T UT32x support])
+fi
+
 AM_CONDITIONAL(HW_VICTOR_DMM, test x$HW_VICTOR_DMM = xyes)
 if test "x$HW_VICTOR_DMM" = "xyes"; then
        AC_DEFINE(HAVE_HW_VICTOR_DMM, 1, [Victor DMM support])
@@ -492,6 +502,7 @@ AC_CONFIG_FILES([Makefile version.h hardware/Makefile
                 hardware/openbench-logic-sniffer/Makefile
                 hardware/serial-dmm/Makefile
                 hardware/uni-t-dmm/Makefile
+                hardware/uni-t-ut32x/Makefile
                 hardware/zeroplus-logic-cube/Makefile
                 input/Makefile
                 output/Makefile
@@ -550,6 +561,7 @@ echo "  - rigol-ds1xx2.................... $HW_RIGOL_DS1XX2"
 echo "  - serial-dmm...................... $HW_SERIAL_DMM"
 echo "  - tondaj-sl-814................... $HW_TONDAJ_SL_814"
 echo "  - uni-t-dmm....................... $HW_UNI_T_DMM"
+echo "  - uni-t-ut32x..................... $HW_UNI_T_UT32X"
 echo "  - victor-dmm...................... $HW_VICTOR_DMM"
 echo "  - zeroplus-logic-cube............. $HW_ZEROPLUS_LOGIC_CUBE"
 echo
index a4b755b43d94d3dee2bdf5666f833fd5b0996470..a779b6bb34a069b65e825bb25f129a7d24293918 100644 (file)
@@ -43,6 +43,7 @@ SUBDIRS = \
        serial-dmm \
        tondaj-sl-814 \
        uni-t-dmm \
+       uni-t-ut32x \
        victor-dmm \
        zeroplus-logic-cube
 
@@ -145,6 +146,10 @@ if HW_UNI_T_DMM
 libsigrokhardware_la_LIBADD += uni-t-dmm/libsigrok_hw_uni_t_dmm.la
 endif
 
+if HW_UNI_T_UT32X
+libsigrokhardware_la_LIBADD += uni-t-ut32x/libsigrok_hw_uni_t_ut32x.la
+endif
+
 if HW_VICTOR_DMM
 libsigrokhardware_la_LIBADD += victor-dmm/libsigrok_hw_victor_dmm.la
 endif
diff --git a/hardware/uni-t-ut32x/Makefile.am b/hardware/uni-t-ut32x/Makefile.am
new file mode 100644 (file)
index 0000000..906be40
--- /dev/null
@@ -0,0 +1,33 @@
+##
+## This file is part of the libsigrok project.
+##
+## Copyright (C) 2013 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/>.
+##
+
+if HW_UNI_T_UT32X
+
+# Local lib, this is NOT meant to be installed!
+noinst_LTLIBRARIES = libsigrok_hw_uni_t_ut32x.la
+
+libsigrok_hw_uni_t_ut32x_la_SOURCES = \
+       api.c \
+       protocol.c \
+       protocol.h
+
+libsigrok_hw_uni_t_ut32x_la_CFLAGS = \
+       -I$(top_srcdir)
+
+endif
diff --git a/hardware/uni-t-ut32x/api.c b/hardware/uni-t-ut32x/api.c
new file mode 100644 (file)
index 0000000..3970b12
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2013 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 uni_t_ut32x_driver_info;
+static struct sr_dev_driver *di = &uni_t_ut32x_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)
+{
+       struct drv_context *drvc;
+
+       drvc = di->priv;
+
+       return drvc->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)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+
+       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)
+{
+       int ret;
+
+       (void)data;
+
+       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)
+{
+       int ret;
+
+       (void)sdi;
+       (void)data;
+
+       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 uni_t_ut32x_driver_info = {
+       .name = "uni-t-ut32x",
+       .longname = "UNI-T UT32x",
+       .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/uni-t-ut32x/protocol.c b/hardware/uni-t-ut32x/protocol.c
new file mode 100644 (file)
index 0000000..edbca3b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2013 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 uni_t_ut32x_receive_data(int fd, int revents, void *cb_data)
+{
+       (void)fd;
+
+       const struct sr_dev_inst *sdi;
+       struct dev_context *devc;
+
+       if (!(sdi = cb_data))
+               return TRUE;
+
+       if (!(devc = sdi->priv))
+               return TRUE;
+
+       if (revents == G_IO_IN) {
+               /* TODO */
+       }
+
+       return TRUE;
+}
diff --git a/hardware/uni-t-ut32x/protocol.h b/hardware/uni-t-ut32x/protocol.h
new file mode 100644 (file)
index 0000000..bcd67c9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2013 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_UNI_T_UT32X_PROTOCOL_H
+#define LIBSIGROK_HARDWARE_UNI_T_UT32X_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 "uni-t-ut32x: "
+#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
+#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
+#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
+#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
+#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
+#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
+
+/** Private, per-device-instance driver context. */
+struct dev_context {
+       /* Model-specific information */
+
+       /* Acquisition settings */
+
+       /* Operational state */
+
+       /* Temporary state across callbacks */
+
+};
+
+SR_PRIV int uni_t_ut32x_receive_data(int fd, int revents, void *cb_data);
+
+#endif
index 9d68a1fc4d79e3be6dbf7fd4cb4a80ceccab9316..da2b1e6c388364a3776ecfdd9897c033d59009b7 100644 (file)
@@ -142,6 +142,9 @@ extern SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info;
 #ifdef HAVE_HW_TONDAJ_SL_814
 extern SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info;
 #endif
+#ifdef HAVE_HW_UNI_T_UT32X
+extern SR_PRIV struct sr_dev_driver uni_t_ut32x_driver_info;
+#endif
 #ifdef HAVE_HW_VICTOR_DMM
 extern SR_PRIV struct sr_dev_driver victor_dmm_driver_info;
 #endif
@@ -249,6 +252,9 @@ static struct sr_dev_driver *drivers_list[] = {
 #ifdef HAVE_HW_TONDAJ_SL_814
        &tondaj_sl_814_driver_info,
 #endif
+#ifdef HAVE_HW_UNI_T_UT32X
+       &uni_t_ut32x_driver_info,
+#endif
 #ifdef HAVE_HW_VICTOR_DMM
        &victor_dmm_driver_info,
 #endif