From: Uwe Hermann Date: Sun, 1 Sep 2013 11:10:54 +0000 (+0200) Subject: Voltcraft VC-830: Fix diode mode handling. X-Git-Tag: libsigrok-0.2.2~66 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e52bb9be8351b8c4f960d998a62dfbd05b8fa637;p=libsigrok.git Voltcraft VC-830: Fix diode mode handling. This DMM is not using the standard bits in the FS9922 protocol/structure to indicate the "volt" and "diode mode" flags. Instead, it only sets the user-defined bit "z1" to indicate both "diode mode" and "volt". This fixes #142. --- diff --git a/hardware/common/dmm/fs9922.c b/hardware/common/dmm/fs9922.c index 9decc786..51d3c654 100644 --- a/hardware/common/dmm/fs9922.c +++ b/hardware/common/dmm/fs9922.c @@ -375,3 +375,17 @@ SR_PRIV int sr_fs9922_parse(const uint8_t *buf, float *floatval, return SR_OK; } + +SR_PRIV void sr_fs9922_z1_diode(struct sr_datafeed_analog *analog, void *info) +{ + struct fs9922_info *info_local; + + info_local = (struct fs9922_info *)info; + + /* User-defined z1 flag means "diode mode". */ + if (info_local->is_z1) { + analog->mq = SR_MQ_VOLTAGE; + analog->unit = SR_UNIT_VOLT; + analog->mqflags |= SR_MQFLAG_DIODE; + } +} diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index b6987947..4e1e1e01 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -172,10 +172,15 @@ SR_PRIV struct dmm_info dmms[] = { receive_data_VOLTCRAFT_VC820_SER, }, { + /* + * Note: The VC830 doesn't set the 'volt' and 'diode' bits of + * the FS9922 protocol. Instead, it only sets the user-defined + * bit "z1" to indicate "diode mode" and "voltage". + */ "Voltcraft", "VC-830 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", 2400, FS9922_PACKET_SIZE, NULL, sr_fs9922_packet_valid, sr_fs9922_parse, - NULL, + &sr_fs9922_z1_diode, &voltcraft_vc830_ser_driver_info, receive_data_VOLTCRAFT_VC830_SER, }, diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index e766fd85..b23fc02c 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -99,10 +99,15 @@ SR_PRIV struct dmm_info udmms[] = { &voltcraft_vc820_driver_info, receive_data_VOLTCRAFT_VC820, }, { + /* + * Note: The VC830 doesn't set the 'volt' and 'diode' bits of + * the FS9922 protocol. Instead, it only sets the user-defined + * bit "z1" to indicate "diode mode" and "voltage". + */ "Voltcraft", "VC-830", 2400, FS9922_PACKET_SIZE, NULL, sr_fs9922_packet_valid, sr_fs9922_parse, - NULL, + &sr_fs9922_z1_diode, &voltcraft_vc830_driver_info, receive_data_VOLTCRAFT_VC830, }, { diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 5fc0fbfa..423463a2 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -213,6 +213,7 @@ struct fs9922_info { SR_PRIV gboolean sr_fs9922_packet_valid(const uint8_t *buf); SR_PRIV int sr_fs9922_parse(const uint8_t *buf, float *floatval, struct sr_datafeed_analog *analog, void *info); +SR_PRIV void sr_fs9922_z1_diode(struct sr_datafeed_analog *analog, void *info); /*--- hardware/common/dmm/fs9721.c ------------------------------------------*/