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).
This commit is contained in:
parent
4853559466
commit
2451a20ff5
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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 -----------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue