]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Add PeakTech 4370 support.
authorUwe Hermann <redacted>
Sun, 2 Dec 2012 00:02:16 +0000 (01:02 +0100)
committerUwe Hermann <redacted>
Sun, 2 Dec 2012 13:22:51 +0000 (14:22 +0100)
hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.c
hardware/serial-dmm/protocol.h
hwdriver.c

index ed94b89c582258113d38e406da187f778bfd628e..bbe5acf50febe97aad26df22094cd36914604885 100644 (file)
@@ -54,6 +54,7 @@ SR_PRIV struct sr_dev_driver peaktech_3410_driver_info;
 SR_PRIV struct sr_dev_driver mastech_mas345_driver_info;
 SR_PRIV struct sr_dev_driver va_va18b_driver_info;
 SR_PRIV struct sr_dev_driver metex_m3640d_driver_info;
+SR_PRIV struct sr_dev_driver peaktech_4370_driver_info;
 
 static struct sr_dev_driver *di_dt4000zc = &digitek_dt4000zc_driver_info;
 static struct sr_dev_driver *di_tp4000zc = &tekpower_tp4000zc_driver_info;
@@ -62,6 +63,7 @@ static struct sr_dev_driver *di_3410 = &peaktech_3410_driver_info;
 static struct sr_dev_driver *di_mas345 = &mastech_mas345_driver_info;
 static struct sr_dev_driver *di_va18b = &va_va18b_driver_info;
 static struct sr_dev_driver *di_m3640d = &metex_m3640d_driver_info;
+static struct sr_dev_driver *di_4370 = &peaktech_4370_driver_info;
 
 /* After hw_init() this will point to a device-specific entry (see above). */
 static struct sr_dev_driver *di = NULL;
@@ -109,6 +111,12 @@ SR_PRIV struct dmm_info dmms[] = {
                sr_metex14_packet_valid, sr_metex14_parse,
                NULL,
        },
+       {
+               "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200,
+               METEX14_PACKET_SIZE, sr_metex14_packet_request,
+               sr_metex14_packet_valid, sr_metex14_parse,
+               NULL,
+       },
 };
 
 /* Properly close and free all devices. */
@@ -160,6 +168,8 @@ static int hw_init(int dmm)
                di = di_va18b;
        if (dmm == METEX_M3640D)
                di = di_m3640d;
+       if (dmm == PEAKTECH_4370)
+               di = di_4370;
        sr_dbg("Selected '%s' subdriver.", di->name);
 
        di->priv = drvc;
@@ -202,6 +212,11 @@ static int hw_init_metex_m3640d(void)
        return hw_init(METEX_M3640D);
 }
 
+static int hw_init_peaktech_4370(void)
+{
+       return hw_init(PEAKTECH_4370);
+}
+
 static GSList *scan(const char *conn, const char *serialcomm, int dmm)
 {
        struct sr_dev_inst *sdi;
@@ -323,6 +338,8 @@ static GSList *hw_scan(GSList *options)
                dmm = 5;
        if (!strcmp(di->name, "metex-m3640d"))
                dmm = 6;
+       if (!strcmp(di->name, "peaktech-4370"))
+               dmm = 7;
 
        if (serialcomm) {
                /* Use the provided comm specs. */
@@ -492,6 +509,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                receive_data = va_va18b_receive_data;
        if (!strcmp(di->name, "metex-m3640d"))
                receive_data = metex_m3640d_receive_data;
+       if (!strcmp(di->name, "peaktech-4370"))
+               receive_data = peaktech_4370_receive_data;
 
        /* Poll every 50ms, or whenever some data comes in. */
        sr_source_add(devc->serial->fd, G_IO_IN, 50,
@@ -651,3 +670,21 @@ SR_PRIV struct sr_dev_driver metex_m3640d_driver_info = {
        .dev_acquisition_stop = hw_dev_acquisition_stop,
        .priv = NULL,
 };
+
+SR_PRIV struct sr_dev_driver peaktech_4370_driver_info = {
+       .name = "peaktech-4370",
+       .longname = "PeakTech 4370",
+       .api_version = 1,
+       .init = hw_init_peaktech_4370,
+       .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,
+};
index 41d2979cf238dd5d77e6c12dc4fedd7a8a12730a..3258369da2b71886f600a32827660584fe162dfc 100644 (file)
@@ -207,3 +207,9 @@ SR_PRIV int metex_m3640d_receive_data(int fd, int revents, void *cb_data)
        struct metex14_info info;
        return receive_data(fd, revents, METEX_M3640D, &info, cb_data);
 }
+
+SR_PRIV int peaktech_4370_receive_data(int fd, int revents, void *cb_data)
+{
+       struct metex14_info info;
+       return receive_data(fd, revents, PEAKTECH_4370, &info, cb_data);
+}
index 18762ef5c7253963590050c878cf1d7edaa3d888..f0658c4708c68f0527f4e01eccdc99a31463fe6a 100644 (file)
@@ -29,6 +29,7 @@
 #define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
 #define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
 
+/* Note: When adding entries here, don't forget to update DMM_COUNT. */
 enum {
        DIGITEK_DT4000ZC,
        TEKPOWER_TP4000ZC,
@@ -37,8 +38,11 @@ enum {
        MASTECH_MAS345,
        VA_VA18B,
        METEX_M3640D,
+       PEAKTECH_4370,
 };
 
+#define DMM_COUNT 8
+
 struct dmm_info {
        char *vendor;
        char *device;
@@ -52,7 +56,7 @@ struct dmm_info {
        void (*dmm_details)(struct sr_datafeed_analog *, void *);
 };
 
-SR_PRIV struct dmm_info dmms[7];
+SR_PRIV struct dmm_info dmms[DMM_COUNT];
 
 #define DMM_BUFSIZE 256
 
@@ -81,6 +85,7 @@ SR_PRIV int peaktech_3410_receive_data(int fd, int revents, void *cb_data);
 SR_PRIV int mastech_mas345_receive_data(int fd, int revents, void *cb_data);
 SR_PRIV int va_va18b_receive_data(int fd, int revents, void *cb_data);
 SR_PRIV int metex_m3640d_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV int peaktech_4370_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);
index 208c6a5e8dfc9571ceac76a8f24f399031ab1cc2..e40e1f676279386064a25c81c5c6f7c57064ee10 100644 (file)
@@ -121,6 +121,7 @@ extern SR_PRIV struct sr_dev_driver peaktech_3410_driver_info;
 extern SR_PRIV struct sr_dev_driver mastech_mas345_driver_info;
 extern SR_PRIV struct sr_dev_driver va_va18b_driver_info;
 extern SR_PRIV struct sr_dev_driver metex_m3640d_driver_info;
+extern SR_PRIV struct sr_dev_driver peaktech_4370_driver_info;
 #endif
 #ifdef HAVE_HW_UNI_T_DMM
 extern SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info;
@@ -182,6 +183,7 @@ static struct sr_dev_driver *drivers_list[] = {
        &mastech_mas345_driver_info,
        &va_va18b_driver_info,
        &metex_m3640d_driver_info,
+       &peaktech_4370_driver_info,
 #endif
 #ifdef HAVE_HW_UNI_T_DMM
        &uni_t_ut61d_driver_info,