From: Uwe Hermann Date: Sat, 1 Dec 2012 22:32:39 +0000 (+0100) Subject: serial-dmm: Add V&A VA18B support. X-Git-Tag: dsupstream~503 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6dca2f16eedfbcaa0ea4e45c7d58bbf596fa1012;p=libsigrok.git serial-dmm: Add V&A VA18B support. --- diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index 56227f8d..fff2aa85 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -52,12 +52,14 @@ SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info; SR_PRIV struct sr_dev_driver metex_me31_driver_info; 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; static struct sr_dev_driver *di_dt4000zc = &digitek_dt4000zc_driver_info; static struct sr_dev_driver *di_tp4000zc = &tekpower_tp4000zc_driver_info; static struct sr_dev_driver *di_me31 = &metex_me31_driver_info; 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; /* After hw_init() this will point to a device-specific entry (see above). */ static struct sr_dev_driver *di = NULL; @@ -93,6 +95,12 @@ SR_PRIV struct dmm_info dmms[] = { sr_metex14_packet_valid, sr_metex14_parse, NULL, }, + { + "V&A", "VA18B", "2400/8n1", 2400, + FS9721_PACKET_SIZE, NULL, + sr_fs9721_packet_valid, sr_fs9721_parse, + dmm_details_va18b, + }, }; /* Properly close and free all devices. */ @@ -140,6 +148,8 @@ static int hw_init(int dmm) di = di_3410; if (dmm == MASTECH_MAS345) di = di_mas345; + if (dmm == VA_VA18B) + di = di_va18b; sr_dbg("Selected '%s' subdriver.", di->name); di->priv = drvc; @@ -172,6 +182,11 @@ static int hw_init_mastech_mas345(void) return hw_init(MASTECH_MAS345); } +static int hw_init_va_va18b(void) +{ + return hw_init(VA_VA18B); +} + static GSList *scan(const char *conn, const char *serialcomm, int dmm) { struct sr_dev_inst *sdi; @@ -289,6 +304,8 @@ static GSList *hw_scan(GSList *options) dmm = 3; if (!strcmp(di->name, "mastech-mas345")) dmm = 4; + if (!strcmp(di->name, "va-va18b")) + dmm = 5; if (serialcomm) { /* Use the provided comm specs. */ @@ -454,6 +471,8 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, receive_data = peaktech_3410_receive_data; if (!strcmp(di->name, "mastech-mas345")) receive_data = mastech_mas345_receive_data; + if (!strcmp(di->name, "va-va18b")) + receive_data = va_va18b_receive_data; /* Poll every 50ms, or whenever some data comes in. */ sr_source_add(devc->serial->fd, G_IO_IN, 50, @@ -577,3 +596,21 @@ SR_PRIV struct sr_dev_driver mastech_mas345_driver_info = { .dev_acquisition_stop = hw_dev_acquisition_stop, .priv = NULL, }; + +SR_PRIV struct sr_dev_driver va_va18b_driver_info = { + .name = "va-va18b", + .longname = "V&A VA18B", + .api_version = 1, + .init = hw_init_va_va18b, + .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, +}; diff --git a/hardware/serial-dmm/protocol.c b/hardware/serial-dmm/protocol.c index 3c6f932a..1f0db9c0 100644 --- a/hardware/serial-dmm/protocol.c +++ b/hardware/serial-dmm/protocol.c @@ -49,7 +49,19 @@ SR_PRIV void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info) /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature. */ if (info_local->is_c2c1_10) { analog->mq = SR_MQ_TEMPERATURE; - /* No Kelvin or Fahrenheit from the device, just Celsius. */ + analog->unit = SR_UNIT_CELSIUS; + } +} + +SR_PRIV void dmm_details_va18b(struct sr_datafeed_analog *analog, void *info) +{ + struct fs9721_info *info_local; + + info_local = (struct fs9721_info *)info; + + /* User-defined FS9721_LP3 flag 'c2c1_01' means temperature. */ + if (info_local->is_c2c1_01) { + analog->mq = SR_MQ_TEMPERATURE; analog->unit = SR_UNIT_CELSIUS; } } @@ -188,3 +200,10 @@ SR_PRIV int mastech_mas345_receive_data(int fd, int revents, void *cb_data) return receive_data(fd, revents, MASTECH_MAS345, &info, cb_data); } + +SR_PRIV int va_va18b_receive_data(int fd, int revents, void *cb_data) +{ + struct fs9721_info info; + + return receive_data(fd, revents, VA_VA18B, &info, cb_data); +} diff --git a/hardware/serial-dmm/protocol.h b/hardware/serial-dmm/protocol.h index 68481435..047c24dd 100644 --- a/hardware/serial-dmm/protocol.h +++ b/hardware/serial-dmm/protocol.h @@ -35,6 +35,7 @@ enum { METEX_ME31, PEAKTECH_3410, MASTECH_MAS345, + VA_VA18B, }; struct dmm_info { @@ -50,7 +51,7 @@ struct dmm_info { void (*dmm_details)(struct sr_datafeed_analog *, void *); }; -SR_PRIV struct dmm_info dmms[5]; +SR_PRIV struct dmm_info dmms[6]; #define DMM_BUFSIZE 256 @@ -77,8 +78,10 @@ SR_PRIV int tekpower_tp4000zc_receive_data(int fd, int revents, void *cb_data); SR_PRIV int metex_me31_receive_data(int fd, int revents, void *cb_data); 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 void dmm_details_tp4000zc(struct sr_datafeed_analog *analog, void *info); SR_PRIV void dmm_details_dt4000zc(struct sr_datafeed_analog *analog, void *info); +SR_PRIV void dmm_details_va18b(struct sr_datafeed_analog *analog, void *info); #endif diff --git a/hwdriver.c b/hwdriver.c index 58dabce4..41bdf24b 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -119,6 +119,7 @@ extern SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info; extern SR_PRIV struct sr_dev_driver metex_me31_driver_info; 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; #endif #ifdef HAVE_HW_UNI_T_DMM extern SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info; @@ -178,6 +179,7 @@ static struct sr_dev_driver *drivers_list[] = { &metex_me31_driver_info, &peaktech_3410_driver_info, &mastech_mas345_driver_info, + &va_va18b_driver_info, #endif #ifdef HAVE_HW_UNI_T_DMM &uni_t_ut61d_driver_info,