]> sigrok.org Git - libsigrok.git/commitdiff
motech-lps-30x: Initial driver framework.
authorMatthias Heidbrink <redacted>
Mon, 19 May 2014 17:23:30 +0000 (19:23 +0200)
committerMatthias Heidbrink <redacted>
Mon, 19 May 2014 17:23:30 +0000 (19:23 +0200)
Makefile.am
configure.ac
hardware/motech-lps-30x/api.c [new file with mode: 0644]
hardware/motech-lps-30x/protocol.c [new file with mode: 0644]
hardware/motech-lps-30x/protocol.h [new file with mode: 0644]
hwdriver.c

index 0bda21322898bc43dad4799f1327fe565e035eba..dbe46665e7d5c3f8248de7dfb6a04838083a5978 100644 (file)
@@ -228,6 +228,12 @@ libsigrok_la_SOURCES += \
        hardware/mic-985xx/protocol.c \
        hardware/mic-985xx/api.c
 endif
+if HW_MOTECH_LPS_30X
+libsigrok_la_SOURCES += \
+       hardware/motech-lps-30x/protocol.h \
+       hardware/motech-lps-30x/protocol.c \
+       hardware/motech-lps-30x/api.c
+endif
 if HW_NORMA_DMM
 libsigrok_la_SOURCES += \
        hardware/norma-dmm/protocol.h \
index cb4eeafc176c8cdbf286e094206d9792d3209d18..6b4548837515b6ee53c98ceac5f2fc2af5bf4e96 100644 (file)
@@ -195,6 +195,11 @@ AC_ARG_ENABLE(mic-985xx, AC_HELP_STRING([--enable-mic-985xx],
        [HW_MIC_985XX="$enableval"],
        [HW_MIC_985XX=$HW_ENABLED_DEFAULT])
 
+AC_ARG_ENABLE(motech-lps-30x, AC_HELP_STRING([--enable-motech-lps-30x],
+       [enable motech-lps-30x support [default=yes]]),
+       [HW_MOTECH_LPS_30X="$enableval"],
+       [HW_MOTECH_LPS_30X=$HW_ENABLED_DEFAULT])
+
 AC_ARG_ENABLE(norma-dmm, AC_HELP_STRING([--enable-norma-dmm],
        [enable Norma DMM support [default=yes]]),
        [HW_NORMA_DMM="$enableval"],
@@ -305,8 +310,9 @@ PKG_CHECK_MODULES([libserialport], [libserialport >= 0.1.0],
        HW_ATTEN_PPS3XXX="no"; HW_BRYMEN_DMM="no"; HW_CEM_DT_885X="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_MIC_985XX="no"; HW_NORMA_DMM="no"; HW_OLS="no";
-       HW_SERIAL_DMM="no"; HW_TELEINFO="no"; HW_TONDAJ_SL_814="no"])
+       HW_MIC_985XX="no"; HW_MOTECH_LPS_30X="no"; HW_NORMA_DMM="no";
+       HW_OLS="no"; HW_SERIAL_DMM="no"; HW_TELEINFO="no";
+       HW_TONDAJ_SL_814="no"])
 
 # Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
 if test "x$have_libserialport" != "xno"; then
@@ -502,6 +508,11 @@ if test "x$HW_MIC_985XX" = "xyes"; then
        AC_DEFINE(HAVE_HW_MIC_985XX, 1, [MIC 985xx support])
 fi
 
+AM_CONDITIONAL(HW_MOTECH_LPS_30X, test x$HW_MOTECH_LPS_30X = xyes)
+if test "x$HW_MOTECH_LPS_30X" = "xyes"; then
+       AC_DEFINE(HAVE_HW_MOTECH_LPS_30X, 1, [motech-lps-30x support])
+fi
+
 AM_CONDITIONAL(HW_NORMA_DMM, test x$HW_NORMA_DMM = xyes)
 if test "x$HW_NORMA_DMM" = "xyes"; then
        AC_DEFINE(HAVE_HW_NORMA_DMM, 1, [Norma DMM support])
@@ -635,6 +646,7 @@ echo "  - ikalogic-scanaplus.............. $HW_IKALOGIC_SCANAPLUS"
 echo "  - kecheng-kc-330b................. $HW_KECHENG_KC_330B"
 echo "  - lascar-el-usb................... $HW_LASCAR_EL_USB"
 echo "  - mic-985xx....................... $HW_MIC_985XX"
+echo "  - motech-lps-30x.................. $HW_MOTECH_LPS_30X"
 echo "  - norma-dmm....................... $HW_NORMA_DMM"
 echo "  - openbench-logic-sniffer......... $HW_OLS"
 echo "  - rigol-ds........................ $HW_RIGOL_DS"
diff --git a/hardware/motech-lps-30x/api.c b/hardware/motech-lps-30x/api.c
new file mode 100644 (file)
index 0000000..0b4f2b2
--- /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 motech_lps_301_driver_info;
+static struct sr_dev_driver *di = &motech_lps_301_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 motech_lps_301_driver_info = {
+       .name = "motech-lps-301",
+       .longname = "Motech LPS-301",
+       .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/motech-lps-30x/protocol.c b/hardware/motech-lps-30x/protocol.c
new file mode 100644 (file)
index 0000000..921b8de
--- /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 motech_lps_30x_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/motech-lps-30x/protocol.h b/hardware/motech-lps-30x/protocol.h
new file mode 100644 (file)
index 0000000..7890654
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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_MOTECH_LPS30X_PROTOCOL_H
+#define LIBSIGROK_HARDWARE_MOTECH_LPS30X_PROTOCOL_H
+
+#include <stdint.h>
+#include <glib.h>
+#include "libsigrok.h"
+#include "libsigrok-internal.h"
+
+#define LOG_PREFIX "motech-lps30x"
+
+/** Private, per-device-instance driver context. */
+struct dev_context {
+       /* Model-specific information */
+
+       /* Acquisition settings */
+
+       /* Operational state */
+
+       /* Temporary state across callbacks */
+
+};
+
+SR_PRIV int motech_lps30x_receive_data(int fd, int revents, void *cb_data);
+
+#endif
index f028ea1067fa7ff3db1b3645db000c66d603d8e8..ecaa3c04b7412095919a16f407135924134ac910 100644 (file)
@@ -177,6 +177,9 @@ extern SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info;
 extern SR_PRIV struct sr_dev_driver mic_98581_driver_info;
 extern SR_PRIV struct sr_dev_driver mic_98583_driver_info;
 #endif
+#ifdef HAVE_HW_MOTECH_LPS_30X
+extern SR_PRIV struct sr_dev_driver motech_lps_301_driver_info;
+#endif
 #ifdef HAVE_HW_NORMA_DMM
 extern SR_PRIV struct sr_dev_driver norma_dmm_driver_info;
 #endif
@@ -332,6 +335,9 @@ static struct sr_dev_driver *drivers_list[] = {
        &mic_98581_driver_info,
        &mic_98583_driver_info,
 #endif
+#ifdef HAVE_HW_MOTECH_LPS_30X
+       &motech_lps_301_driver_info,
+#endif
 #ifdef HAVE_HW_NORMA_DMM
        &norma_dmm_driver_info,
 #endif