X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fvc870.c;h=2529f0baeb12f63c741fc7f97117e962e76908c5;hb=4867dd177f1dbaf99e44c29548d614d3f324eeb9;hp=29ec2e2fd7b40f57320499cd2562fdbcda8a2ae0;hpb=e57057aee778e723da572a6b5e2bd01526cc7beb;p=libsigrok.git diff --git a/src/dmm/vc870.c b/src/dmm/vc870.c index 29ec2e2f..2529f0ba 100644 --- a/src/dmm/vc870.c +++ b/src/dmm/vc870.c @@ -46,11 +46,17 @@ static const float factors[][8] = { {1e-4, 0, 0, 0, 0, 0, 0, 0}, /* Diode */ {1e-3, 1e-2, 1e-1, 1, 1e1, 1e2, 1e3, 1e4}, /* Frequency */ {1e-2, 0, 0, 0, 0, 0, 0, 0}, /* Loop current */ + /* + * Note: Measurements showed that AC and DC differ + * in the factors used, although docs say they should + * be the same. + */ {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* DCµA */ - {1e-8, 1e-7, 0, 0, 0, 0, 0, 0}, /* ACµA */ + {1e-7, 1e-6, 0, 0, 0, 0, 0, 0}, /* ACµA */ {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* DCmA */ - {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* ACmA */ + {1e-5, 1e-4, 0, 0, 0, 0, 0, 0}, /* ACmA */ {1e-3, 0, 0, 0, 0, 0, 0, 0}, /* DCA */ + /* TODO: Verify factor for ACA */ {1e-3, 0, 0, 0, 0, 0, 0, 0}, /* ACA */ {1e-1, 0, 0, 0, 0, 0, 0, 0}, /* Act+apparent power */ {1e-1, 0, 0, 0, 0, 0, 0, 0}, /* Power factor / freq */ @@ -61,7 +67,6 @@ static int parse_value(const uint8_t *buf, struct vc870_info *info, float *result) { int i, intval; - float floatval; /* Bytes 3-7: Main display value (5 decimal digits) */ if (info->is_open || info->is_ol1) { @@ -86,13 +91,11 @@ static int parse_value(const uint8_t *buf, struct vc870_info *info, intval *= info->is_sign1 ? -1 : 1; // intval *= info->is_sign2 ? -1 : 1; /* TODO: Fahrenheit / aux display. */ - floatval = (float)intval; - /* Note: The decimal point position will be parsed later. */ - sr_spew("The display value is %f.", floatval); + sr_spew("The display value without comma is %05d.", intval); - *result = floatval; + *result = (float)intval; return SR_OK; } @@ -280,7 +283,7 @@ static void parse_flags(const uint8_t *buf, struct vc870_info *info) info->is_rms = TRUE; } -static void handle_flags(struct sr_datafeed_analog *analog, +static void handle_flags(struct sr_datafeed_analog_old *analog, float *floatval, const struct vc870_info *info) { /* @@ -334,13 +337,6 @@ static void handle_flags(struct sr_datafeed_analog *analog, analog->mq = SR_MQ_POWER; analog->unit = SR_UNIT_WATT; } - if (info->is_power_factor_freq) { - /* TODO: Handle power factor. */ - // analog->mq = SR_MQ_POWER_FACTOR; - // analog->unit = SR_UNIT_UNITLESS; - analog->mq = SR_MQ_FREQUENCY; - analog->unit = SR_UNIT_HERTZ; - } if (info->is_power_apparent_power) { analog->mq = SR_MQ_POWER; analog->unit = SR_UNIT_WATT; @@ -348,6 +344,13 @@ static void handle_flags(struct sr_datafeed_analog *analog, // analog->mq = SR_MQ_APPARENT_POWER; // analog->unit = SR_UNIT_VOLT_AMPERE; } + if (info->is_power_factor_freq) { + /* TODO: Handle power factor. */ + // analog->mq = SR_MQ_POWER_FACTOR; + // analog->unit = SR_UNIT_UNITLESS; + analog->mq = SR_MQ_FREQUENCY; + analog->unit = SR_UNIT_HERTZ; + } /* Measurement related flags */ if (info->is_ac) @@ -402,7 +405,7 @@ SR_PRIV gboolean sr_vc870_packet_valid(const uint8_t *buf) } SR_PRIV int sr_vc870_parse(const uint8_t *buf, float *floatval, - struct sr_datafeed_analog *analog, void *info) + struct sr_datafeed_analog_old *analog, void *info) { int ret; struct vc870_info *info_local;