From: Uwe Hermann Date: Wed, 1 May 2013 00:10:56 +0000 (+0200) Subject: fs9721: Factor out common code from serial-dmm. X-Git-Tag: dsupstream~16 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2451a20ff5137d178ed4a02ee04076c6eae97235;p=libsigrok.git fs9721: Factor out common code from serial-dmm. These functions are FS9721 specific (and DMM specific), and can be used from various drivers (e.g. serial-dmm or uni-t-dmm or possibly others). --- diff --git a/hardware/common/dmm/fs9721.c b/hardware/common/dmm/fs9721.c index a914add8..17a03a62 100644 --- a/hardware/common/dmm/fs9721.c +++ b/hardware/common/dmm/fs9721.c @@ -369,7 +369,7 @@ SR_PRIV int sr_fs9721_parse(const uint8_t *buf, float *floatval, return SR_OK; } -SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *analog, void *info) +SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info) { struct fs9721_info *info_local; @@ -381,3 +381,48 @@ SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *a analog->unit = SR_UNIT_CELSIUS; } } + +SR_PRIV void sr_fs9721_01_temp_c(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 (C). */ + if (info_local->is_c2c1_01) { + analog->mq = SR_MQ_TEMPERATURE; + analog->unit = SR_UNIT_CELSIUS; + } +} + +SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info) +{ + struct fs9721_info *info_local; + + info_local = (struct fs9721_info *)info; + + /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */ + if (info_local->is_c2c1_10) { + analog->mq = SR_MQ_TEMPERATURE; + analog->unit = SR_UNIT_CELSIUS; + } +} + +SR_PRIV void sr_fs9721_01_10_temp_f_c(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 (F). */ + if (info_local->is_c2c1_01) { + analog->mq = SR_MQ_TEMPERATURE; + analog->unit = SR_UNIT_FAHRENHEIT; + } + + /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */ + if (info_local->is_c2c1_10) { + analog->mq = SR_MQ_TEMPERATURE; + analog->unit = SR_UNIT_CELSIUS; + } +} diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index c0eeba04..e950c303 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -63,14 +63,14 @@ SR_PRIV struct dmm_info dmms[] = { "Digitek", "DT4000ZC", "2400/8n1", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - dmm_details_dt4000zc, + sr_fs9721_10_temp_c, &digitek_dt4000zc_driver_info, receive_data_DIGITEK_DT4000ZC, }, { "TekPower", "TP4000ZC", "2400/8n1", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - dmm_details_tp4000zc, + sr_fs9721_10_temp_c, &tekpower_tp4000zc_driver_info, receive_data_TEKPOWER_TP4000ZC, }, { @@ -98,7 +98,7 @@ SR_PRIV struct dmm_info dmms[] = { "V&A", "VA18B", "2400/8n1", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - dmm_details_va18b, + sr_fs9721_01_temp_c, &va_va18b_driver_info, receive_data_VA_VA18B, }, { @@ -119,7 +119,7 @@ SR_PRIV struct dmm_info dmms[] = { "PCE", "PCE-DM32", "2400/8n1", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - dmm_details_pce_dm32, + sr_fs9721_01_10_temp_f_c, &pce_pce_dm32_driver_info, receive_data_PCE_PCE_DM32, }, { @@ -155,7 +155,7 @@ SR_PRIV struct dmm_info dmms[] = { "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_details_c2c1_00_temp_celsius, + sr_fs9721_00_temp_c, &voltcraft_vc840_ser_driver_info, receive_data_VOLTCRAFT_VC840_SER, }, diff --git a/hardware/serial-dmm/protocol.c b/hardware/serial-dmm/protocol.c index 6e697586..a21d2472 100644 --- a/hardware/serial-dmm/protocol.c +++ b/hardware/serial-dmm/protocol.c @@ -35,56 +35,6 @@ 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; - - info_local = (struct fs9721_info *)info; - - /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */ - if (info_local->is_c2c1_10) { - analog->mq = SR_MQ_TEMPERATURE; - 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 (C). */ - if (info_local->is_c2c1_01) { - analog->mq = SR_MQ_TEMPERATURE; - analog->unit = SR_UNIT_CELSIUS; - } -} - -SR_PRIV void dmm_details_pce_dm32(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 (F). */ - if (info_local->is_c2c1_01) { - analog->mq = SR_MQ_TEMPERATURE; - analog->unit = SR_UNIT_FAHRENHEIT; - } - - /* User-defined FS9721_LP3 flag 'c2c1_10' means temperature (C). */ - if (info_local->is_c2c1_10) { - analog->mq = SR_MQ_TEMPERATURE; - analog->unit = SR_UNIT_CELSIUS; - } -} - static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, int dmm, void *info) { diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index 1e8a621c..4e8fe349 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -68,7 +68,7 @@ SR_PRIV struct dmm_info udmms[] = { "Voltcraft", "VC-840", 2400, FS9721_PACKET_SIZE, NULL, sr_fs9721_packet_valid, sr_fs9721_parse, - sr_fs9721_details_c2c1_00_temp_celsius, + sr_fs9721_00_temp_c, &voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840, }, }; diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 4396cc15..57005cd2 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -228,7 +228,10 @@ struct fs9721_info { SR_PRIV gboolean sr_fs9721_packet_valid(const uint8_t *buf); SR_PRIV int sr_fs9721_parse(const uint8_t *buf, float *floatval, struct sr_datafeed_analog *analog, void *info); -SR_PRIV void sr_fs9721_details_c2c1_00_temp_celsius(struct sr_datafeed_analog *analog, void *info); +SR_PRIV void sr_fs9721_00_temp_c(struct sr_datafeed_analog *analog, void *info); +SR_PRIV void sr_fs9721_01_temp_c(struct sr_datafeed_analog *analog, void *info); +SR_PRIV void sr_fs9721_10_temp_c(struct sr_datafeed_analog *analog, void *info); +SR_PRIV void sr_fs9721_01_10_temp_f_c(struct sr_datafeed_analog *analog, void *info); /*--- hardware/common/dmm/metex14.c -----------------------------------------*/