]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Add Digitek DT4000ZC support.
authorUwe Hermann <redacted>
Sat, 1 Dec 2012 18:53:05 +0000 (19:53 +0100)
committerUwe Hermann <redacted>
Sun, 2 Dec 2012 13:21:19 +0000 (14:21 +0100)
hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.c
hardware/serial-dmm/protocol.h
hwdriver.c

index 4293d6354ace16ec260fd304ba1f356033925632..4ac923cac6cb0458255d53abc9fbba8ece5a2b78 100644 (file)
@@ -47,13 +47,24 @@ static const char *probe_names[] = {
        NULL,
 };
 
+SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info;
 SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info;
+
+static struct sr_dev_driver *di_digitek_dt4000zc = &digitek_dt4000zc_driver_info;
 static struct sr_dev_driver *di_tekpower_tp4000zc = &tekpower_tp4000zc_driver_info;
 
 /* After hw_init() this will point to a device-specific entry (see above). */
 static struct sr_dev_driver *di = NULL;
 
 SR_PRIV struct dmm_info dmms[] = {
+       {
+               "Digitek", "DT4000ZC",
+               "2400/8n1", 2400,
+               FS9721_PACKET_SIZE,
+               sr_fs9721_packet_valid,
+               sr_fs9721_parse,
+               dmm_details_dt4000zc,
+       },
        {
                "TekPower", "TP4000ZC",
                "2400/8n1", 2400,
@@ -99,6 +110,8 @@ static int hw_init(int dmm)
                return SR_ERR_MALLOC;
        }
 
+       if (dmm == DIGITEK_DT4000ZC)
+               di = di_digitek_dt4000zc;
        if (dmm == TEKPOWER_TP4000ZC)
                di = di_tekpower_tp4000zc;
        sr_dbg("Selected '%s' subdriver.", di->name);
@@ -108,6 +121,11 @@ static int hw_init(int dmm)
        return SR_OK;
 }
 
+static int hw_init_digitek_dt4000zc(void)
+{
+       return hw_init(DIGITEK_DT4000ZC);
+}
+
 static int hw_init_tekpower_tp4000zc(void)
 {
        return hw_init(TEKPOWER_TP4000ZC);
@@ -212,8 +230,10 @@ static GSList *hw_scan(GSList *options)
        if (!conn)
                return NULL;
 
-       if (!strcmp(di->name, "tekpower-tp4000zc"))
+       if (!strcmp(di->name, "digitek-dt4000zc"))
                dmm = 0;
+       if (!strcmp(di->name, "tekpower-tp4000zc"))
+               dmm = 1;
 
        if (serialcomm) {
                /* Use the provided comm specs. */
@@ -369,6 +389,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        meta.num_probes = 1;
        sr_session_send(devc->cb_data, &packet);
 
+       if (!strcmp(di->name, "digitek-dt4000zc"))
+               receive_data = digitek_dt4000zc_receive_data;
        if (!strcmp(di->name, "tekpower-tp4000zc"))
                receive_data = tekpower_tp4000zc_receive_data;
 
@@ -405,6 +427,24 @@ static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
        return SR_OK;
 }
 
+SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info = {
+       .name = "digitek-dt4000zc",
+       .longname = "Digitek DT4000ZC",
+       .api_version = 1,
+       .init = hw_init_digitek_dt4000zc,
+       .cleanup = hw_cleanup,
+       .scan = hw_scan,
+       .dev_list = hw_dev_list,
+       .dev_clear = clear_instances,
+       .dev_open = hw_dev_open,
+       .dev_close = hw_dev_close,
+       .info_get = hw_info_get,
+       .dev_config_set = hw_dev_config_set,
+       .dev_acquisition_start = hw_dev_acquisition_start,
+       .dev_acquisition_stop = hw_dev_acquisition_stop,
+       .priv = NULL,
+};
+
 SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info = {
        .name = "tekpower-tp4000zc",
        .longname = "TekPower TP4000ZC",
index eabca4865c88f0053a2108586afdcd8a72daadb8..a3f25d0eea5b3941ae57eeabc5fd94a7345706cc 100644 (file)
@@ -35,6 +35,11 @@ static void log_dmm_packet(const uint8_t *buf)
               buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]);
 }
 
+SR_PRIV void dmm_details_dt4000zc(struct sr_datafeed_analog *analog, void *info)
+{
+       dmm_details_tp4000zc(analog, info); /* Same as TP4000ZC. */
+}
+
 SR_PRIV void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info)
 {
        struct fs9721_info *info_local;
@@ -138,6 +143,13 @@ static int receive_data(int fd, int revents, int dmm, void *info, void *cb_data)
        return TRUE;
 }
 
+SR_PRIV int digitek_dt4000zc_receive_data(int fd, int revents, void *cb_data)
+{
+       struct fs9721_info info;
+
+       return receive_data(fd, revents, DIGITEK_DT4000ZC, &info, cb_data);
+}
+
 SR_PRIV int tekpower_tp4000zc_receive_data(int fd, int revents, void *cb_data)
 {
        struct fs9721_info info;
index ba5eaa5df163e2978cc76b5f140c62ca15cac70b..a4333fde87b7e7848c252a08453bb4d48616a8eb 100644 (file)
@@ -30,6 +30,7 @@
 #define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
 
 enum {
+       DIGITEK_DT4000ZC,
        TEKPOWER_TP4000ZC,
 };
 
@@ -45,7 +46,7 @@ struct dmm_info {
        void (*dmm_details)(struct sr_datafeed_analog *, void *);
 };
 
-SR_PRIV struct dmm_info dmms[1];
+SR_PRIV struct dmm_info dmms[2];
 
 #define DMM_BUFSIZE 256
 
@@ -67,7 +68,10 @@ struct dev_context {
        int buflen;
 };
 
+SR_PRIV int digitek_dt4000zc_receive_data(int fd, int revents, void *cb_data);
 SR_PRIV int tekpower_tp4000zc_receive_data(int fd, int revents, void *cb_data);
+
 SR_PRIV void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info);
+SR_PRIV void dmm_details_dt4000zc(struct sr_datafeed_analog *analog, void *info);
 
 #endif
index c377b2d5da312be5c0909052bb7c20552b0b0073..95bdbbf51b784e9fab455cfa306546744ac4f7f2 100644 (file)
@@ -114,6 +114,7 @@ extern SR_PRIV struct sr_dev_driver flukedmm_driver_info;
 extern SR_PRIV struct sr_dev_driver radioshackdmm_driver_info;
 #endif
 #ifdef HAVE_HW_SERIAL_DMM
+extern SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info;
 extern SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info;
 #endif
 #ifdef HAVE_HW_UNI_T_DMM
@@ -169,6 +170,7 @@ static struct sr_dev_driver *drivers_list[] = {
        &radioshackdmm_driver_info,
 #endif
 #ifdef HAVE_HW_SERIAL_DMM
+       &digitek_dt4000zc_driver_info,
        &tekpower_tp4000zc_driver_info,
 #endif
 #ifdef HAVE_HW_UNI_T_DMM