From: Uwe Hermann Date: Mon, 29 Dec 2014 22:30:41 +0000 (+0100) Subject: Add initial Voltcraft VC-870 support. X-Git-Tag: libsigrok-0.4.0~588 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=c36f78f7728e8b5263bed440530a61caa6e30a26 Add initial Voltcraft VC-870 support. There are a few details that have yet to be implemented or reverse engineered and tested. --- diff --git a/Makefile.am b/Makefile.am index 2f56b49a..bf980c22 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,7 +116,8 @@ libsigrok_la_SOURCES += \ src/dmm/rs9lcd.c \ src/dmm/bm25x.c \ src/dmm/ut71x.c \ - src/dmm/ut372.c + src/dmm/ut372.c \ + src/dmm/vc870.c # Hardware (LCR chip parsers) if NEED_SERIAL diff --git a/README.devices b/README.devices index 0382ebc8..11b54bf5 100644 --- a/README.devices +++ b/README.devices @@ -327,6 +327,7 @@ a short list for convenience: - V&A VA18B/VA40B: Keep the "Hz/DUTY" key pressed while powering on the DMM. - Victor 70C/86C: Press the "REL/RS232" button for roughly 1 second. - Voltcraft VC-830: Press the "REL/PC" button for roughly 2 seconds. + - Voltcraft VC-870: Press the "REL/PC" button for roughly 1 second. ChronoVu LA8/LA16 USB VID/PIDs diff --git a/src/dmm/vc870.c b/src/dmm/vc870.c new file mode 100644 index 00000000..bf02e8e9 --- /dev/null +++ b/src/dmm/vc870.c @@ -0,0 +1,427 @@ +/* + * This file is part of the libsigrok project. + * + * Copyright (C) 2014-2015 Uwe Hermann + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include "libsigrok.h" +#include "libsigrok-internal.h" + +#define LOG_PREFIX "vc870" + +/* Factors for the respective measurement mode (0 means "invalid"). */ +static const float factors[][8] = { + {1e-4, 1e-3, 1e-2, 1e-1, 0, 0, 0, 0}, /* DCV */ + {1e-3, 1e-2, 1e-1, 1, 0, 0, 0, 0}, /* ACV */ + {1e-5, 0, 0, 0, 0, 0, 0, 0}, /* DCmV */ + {1e-1, 0, 0, 0, 0, 0, 0, 0}, /* Temperature (C) */ +// {1e-2, 0, 0, 0, 0, 0, 0, 0}, /* TODO: Temperature (F) */ + /* + * Note: The sequence 1e-1 -> 1e1 for the resistance + * value is correct and verified in practice! + * Don't trust the vendor docs on this. + */ + {1e-2, 1e-1, 1e1, 1e2, 1e3, 1e4, 0, 0}, /* Resistance */ + {1e-2, 0, 0, 0, 0, 0, 0, 0}, /* Continuity */ + {1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 0}, /* Capacitance */ + {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 */ + {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-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* DCmA */ + {1e-6, 1e-5, 0, 0, 0, 0, 0, 0}, /* ACmA */ + {1e-3, 0, 0, 0, 0, 0, 0, 0}, /* DCA */ + {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 */ + {1e-1, 0, 0, 0, 0, 0, 0, 0}, /* V eff + A eff */ +}; + +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) { + sr_spew("Over limit."); + *result = INFINITY; + return SR_OK; + } else if (!isdigit(buf[3]) || !isdigit(buf[4]) || + !isdigit(buf[5]) || !isdigit(buf[6]) || !isdigit(buf[7])) { + sr_dbg("Invalid digits: %02x %02x %02x %02x %02X " + "(%c %c %c %c %c).", buf[3], buf[4], buf[5], buf[6], + buf[7]); + return SR_ERR; + } + + intval = 0; + for (i = 0; i < 5; i++) + intval = 10 * intval + (buf[i + 3] - '0'); /* Main display. */ + // intval = 10 * intval + (buf[i + 8] - '0'); /* TODO: Aux display. */ + + /* Apply sign. */ + 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); + + *result = floatval; + + return SR_OK; +} + +static int parse_range(uint8_t b, float *floatval, + const struct vc870_info *info) +{ + int idx, mode; + float factor = 0; + + idx = b - '0'; + + if (idx < 0 || idx > 7) { + sr_dbg("Invalid range byte / index: 0x%02x / 0x%02x.", b, idx); + return SR_ERR; + } + + /* Parse range byte (depends on the measurement mode). */ + if (info->is_voltage && info->is_dc && !info->is_milli) + mode = 0; /* DCV */ + else if (info->is_voltage && info->is_ac) + mode = 1; /* ACV */ + else if (info->is_voltage && info->is_dc && info->is_milli) + mode = 2; /* DCmV */ + else if (info->is_temperature) + mode = 3; /* Temperature */ + else if (info->is_resistance || info->is_continuity) + mode = 4; /* Resistance */ + else if (info->is_continuity) + mode = 5; /* Continuity */ + else if (info->is_capacitance) + mode = 6; /* Capacitance */ + else if (info->is_diode) + mode = 7; /* Diode */ + else if (info->is_frequency) + mode = 8; /* Frequency */ + else if (info->is_loop_current) + mode = 9; /* Loop current */ + else if (info->is_current && info->is_micro && info->is_dc) + mode = 10; /* DCµA */ + else if (info->is_current && info->is_micro && info->is_ac) + mode = 11; /* ACµA */ + else if (info->is_current && info->is_milli && info->is_dc) + mode = 12; /* DCmA */ + else if (info->is_current && info->is_milli && info->is_ac) + mode = 13; /* ACmA */ + else if (info->is_current && !info->is_milli && !info->is_micro && info->is_dc) + mode = 14; /* DCA */ + else if (info->is_current && !info->is_milli && !info->is_micro && info->is_ac) + mode = 15; /* ACA */ + else if (info->is_power_apparent_power) + mode = 16; /* Act+apparent power */ + else if (info->is_power_factor_freq) + mode = 17; /* Power factor / freq */ + else if (info->is_v_a_eff_value) + mode = 18; /* V eff + A eff */ + else { + sr_dbg("Invalid mode, range byte was: 0x%02x.", b); + return SR_ERR; + } + + factor = factors[mode][idx]; + + if (factor == 0) { + sr_dbg("Invalid factor for range byte: 0x%02x (mode=%d, idx=%d).", b, mode, idx); + return SR_ERR; + } + + /* Apply respective factor (mode-dependent) on the value. */ + *floatval *= factor; + sr_dbg("Applying factor %f, new value is %f.", factor, *floatval); + + return SR_OK; +} + +static void parse_flags(const uint8_t *buf, struct vc870_info *info) +{ + /* Bytes 0/1: Function / function select */ + /* Note: Some of these mappings are fixed up later. */ + switch (buf[0]) { + case 0x30: /* DCV / ACV */ + info->is_voltage = TRUE; + info->is_dc = (buf[1] == 0x30); + info->is_ac = (buf[1] == 0x31); + break; + case 0x31: /* DCmV / Celsius */ + if (buf[1] == 0x30) + info->is_voltage = info->is_milli = info->is_dc = TRUE; + else if (buf[1] == 0x31) + info->is_temperature = TRUE; + break; + case 0x32: /* Resistance / Short-circuit test */ + info->is_resistance = (buf[1] == 0x30); + info->is_continuity = (buf[1] == 0x31); + break; + case 0x33: /* Capacitance */ + info->is_capacitance = (buf[1] == 0x30); + break; + case 0x34: /* Diode */ + info->is_diode = (buf[1] == 0x30); + break; + case 0x35: /* (4~20mA)% */ + info->is_frequency = (buf[1] == 0x30); + info->is_loop_current = (buf[1] == 0x31); + break; + case 0x36: /* DCµA / ACµA */ + info->is_current = info->is_micro = TRUE; + info->is_dc = (buf[1] == 0x30); + info->is_ac = (buf[1] == 0x31); + break; + case 0x37: /* DCmA / ACmA */ + info->is_current = info->is_milli = TRUE; + info->is_dc = (buf[1] == 0x30); + info->is_ac = (buf[1] == 0x31); + break; + case 0x38: /* DCA / ACA */ + info->is_current = TRUE; + info->is_dc = (buf[1] == 0x30); + info->is_ac = (buf[1] == 0x31); + break; + case 0x39: /* Active power + apparent power / power factor + frequency */ + if (buf[1] == 0x30) + /* Active power + apparent power */ + info->is_power_apparent_power = TRUE; + else if (buf[1] == 0x31) + /* Power factor + frequency */ + info->is_power_factor_freq = TRUE; + else if (buf[1] == 0x32) + /* Voltage effective value + current effective value */ + info->is_v_a_eff_value = TRUE; + break; + default: + sr_dbg("Invalid function bytes: %02x %02x.", buf[0], buf[1]); + break; + } + + /* Byte 2: Range */ + + /* Byte 3-7: Main display digits */ + + /* Byte 8-12: Auxiliary display digits */ + + /* Byte 13: TODO: "Simulate strip tens digit". */ + + /* Byte 14: TODO: "Simulate strip the single digit". */ + + /* Byte 15: Status */ + info->is_sign2 = (buf[15] & (1 << 3)) != 0; + info->is_sign1 = (buf[15] & (1 << 2)) != 0; + info->is_batt = (buf[15] & (1 << 1)) != 0; /* Bat. low */ + info->is_ol1 = (buf[15] & (1 << 0)) != 0; /* Overflow (main display) */ + + /* Byte 16: Option 1 */ + info->is_max = (buf[16] & (1 << 3)) != 0; + info->is_min = (buf[16] & (1 << 2)) != 0; + info->is_maxmin = (buf[16] & (1 << 1)) != 0; + info->is_rel = (buf[16] & (1 << 0)) != 0; + + /* Byte 17: Option 2 */ + info->is_ol2 = (buf[17] & (1 << 3)) != 0; + info->is_open = (buf[17] & (1 << 2)) != 0; + info->is_manu = (buf[17] & (1 << 1)) != 0; /* Manual mode */ + info->is_hold = (buf[17] & (1 << 0)) != 0; /* Hold */ + + /* Byte 18: Option 3 */ + info->is_light = (buf[18] & (1 << 3)) != 0; + info->is_usb = (buf[18] & (1 << 2)) != 0; /* Always on */ + info->is_warning = (buf[18] & (1 << 1)) != 0; /* Never seen? */ + info->is_auto_power = (buf[18] & (1 << 0)) != 0; /* Always on */ + + /* Byte 19: Option 4 */ + info->is_misplug_warn = (buf[19] & (1 << 3)) != 0; /* Never gets set? */ + info->is_lo = (buf[19] & (1 << 2)) != 0; + info->is_hi = (buf[19] & (1 << 1)) != 0; + info->is_open2 = (buf[19] & (1 << 0)) != 0; /* TODO: Unknown. */ + + /* Byte 20: Dual display bit */ + info->is_dual_display = (buf[20] & (1 << 0)) != 0; + + /* Byte 21: Always '\r' (carriage return, 0x0d, 13) */ + + /* Byte 22: Always '\n' (newline, 0x0a, 10) */ + + info->is_auto = !info->is_manu; + info->is_rms = TRUE; +} + +static void handle_flags(struct sr_datafeed_analog *analog, + float *floatval, const struct vc870_info *info) +{ + /* + * Note: is_micro etc. are not used directly to multiply/divide + * floatval, this is handled via parse_range() and factors[][]. + */ + + /* Measurement modes */ + if (info->is_voltage) { + analog->mq = SR_MQ_VOLTAGE; + analog->unit = SR_UNIT_VOLT; + } + if (info->is_current) { + analog->mq = SR_MQ_CURRENT; + analog->unit = SR_UNIT_AMPERE; + } + if (info->is_resistance) { + analog->mq = SR_MQ_RESISTANCE; + analog->unit = SR_UNIT_OHM; + } + if (info->is_frequency) { + analog->mq = SR_MQ_FREQUENCY; + analog->unit = SR_UNIT_HERTZ; + } + if (info->is_capacitance) { + analog->mq = SR_MQ_CAPACITANCE; + analog->unit = SR_UNIT_FARAD; + } + if (info->is_temperature) { + analog->mq = SR_MQ_TEMPERATURE; + analog->unit = SR_UNIT_CELSIUS; + /* TODO: Handle Fahrenheit in auxiliary display. */ + // analog->unit = SR_UNIT_FAHRENHEIT; + } + if (info->is_continuity) { + analog->mq = SR_MQ_CONTINUITY; + analog->unit = SR_UNIT_BOOLEAN; + /* Vendor docs: "< 20 Ohm acoustic" */ + *floatval = (*floatval < 0.0 || *floatval > 20.0) ? 0.0 : 1.0; + } + if (info->is_diode) { + analog->mq = SR_MQ_VOLTAGE; + analog->unit = SR_UNIT_VOLT; + } + if (info->is_loop_current) { + /* 4mA = 0%, 20mA = 100% */ + analog->mq = SR_MQ_CURRENT; + analog->unit = SR_UNIT_PERCENTAGE; + } + if (info->is_power) { + 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; + /* TODO: Handle apparent power. */ + // analog->mq = SR_MQ_APPARENT_POWER; + // analog->unit = SR_UNIT_VOLT_AMPERE; + } + + /* Measurement related flags */ + if (info->is_ac) + analog->mqflags |= SR_MQFLAG_AC; + if (info->is_dc) + analog->mqflags |= SR_MQFLAG_DC; + if (info->is_auto) + analog->mqflags |= SR_MQFLAG_AUTORANGE; + if (info->is_diode) + analog->mqflags |= SR_MQFLAG_DIODE; + if (info->is_hold) + /* + * Note: HOLD only affects the number displayed on the LCD, + * but not the value sent via the protocol! It also does not + * affect the bargraph on the LCD. + */ + analog->mqflags |= SR_MQFLAG_HOLD; + if (info->is_max) + analog->mqflags |= SR_MQFLAG_MAX; + if (info->is_min) + analog->mqflags |= SR_MQFLAG_MIN; + if (info->is_rel) + analog->mqflags |= SR_MQFLAG_RELATIVE; + + /* Other flags */ + if (info->is_batt) + sr_spew("Battery is low."); + if (info->is_auto_power) + sr_spew("Auto-Power-Off enabled."); +} + +static gboolean flags_valid(const struct vc870_info *info) +{ + /* TODO: Implement. */ + return TRUE; +} + +SR_PRIV gboolean sr_vc870_packet_valid(const uint8_t *buf) +{ + struct vc870_info info; + + /* Byte 21: Always '\r' (carriage return, 0x0d, 13) */ + /* Byte 22: Always '\n' (newline, 0x0a, 10) */ + if (buf[21] != '\r' || buf[22] != '\n') + return FALSE; + + parse_flags(buf, &info); + + return flags_valid(&info); +} + +SR_PRIV int sr_vc870_parse(const uint8_t *buf, float *floatval, + struct sr_datafeed_analog *analog, void *info) +{ + int ret; + struct vc870_info *info_local; + + info_local = (struct vc870_info *)info; + + info_local = (struct vc870_info *)info; + memset(info_local, 0, sizeof(struct vc870_info)); + + if (!sr_vc870_packet_valid(buf)) + return SR_ERR; + + parse_flags(buf, info_local); + + if ((ret = parse_value(buf, info_local, floatval)) != SR_OK) { + sr_dbg("Error parsing value: %d.", ret); + return ret; + } + + if ((ret = parse_range(buf[2], floatval, info_local)) != SR_OK) + return ret; + + handle_flags(analog, floatval, info_local); + + return SR_OK; +} diff --git a/src/drivers.c b/src/drivers.c index c80af43f..6a4e2446 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -152,6 +152,7 @@ extern SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info; +extern SR_PRIV struct sr_dev_driver voltcraft_vc870_ser_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc920_ser_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc940_ser_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc960_ser_driver_info; @@ -202,6 +203,7 @@ extern SR_PRIV struct sr_dev_driver uni_t_ut71e_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc830_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc840_driver_info; +extern SR_PRIV struct sr_dev_driver voltcraft_vc870_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc920_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc940_driver_info; extern SR_PRIV struct sr_dev_driver voltcraft_vc960_driver_info; @@ -353,6 +355,7 @@ SR_PRIV struct sr_dev_driver *drivers_list[] = { &voltcraft_vc820_ser_driver_info, &voltcraft_vc830_ser_driver_info, &voltcraft_vc840_ser_driver_info, + &voltcraft_vc870_ser_driver_info, &voltcraft_vc920_ser_driver_info, &voltcraft_vc940_ser_driver_info, &voltcraft_vc960_ser_driver_info, @@ -403,6 +406,7 @@ SR_PRIV struct sr_dev_driver *drivers_list[] = { &voltcraft_vc820_driver_info, &voltcraft_vc830_driver_info, &voltcraft_vc840_driver_info, + &voltcraft_vc870_driver_info, &voltcraft_vc920_driver_info, &voltcraft_vc940_driver_info, &voltcraft_vc960_driver_info, diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 0387c95a..64b818af 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -65,6 +65,7 @@ SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info; +SR_PRIV struct sr_dev_driver voltcraft_vc870_ser_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc920_ser_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc940_ser_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc960_ser_driver_info; @@ -263,6 +264,13 @@ SR_PRIV struct dmm_info dmms[] = { &voltcraft_vc840_ser_driver_info, receive_data_VOLTCRAFT_VC840_SER, }, + { + "Voltcraft", "VC-870 (UT-D02 cable)", "9600/8n1/rts=0/dtr=1", + 9600, VC870_PACKET_SIZE, 0, 0, NULL, + sr_vc870_packet_valid, sr_vc870_parse, + NULL, + &voltcraft_vc870_ser_driver_info, receive_data_VOLTCRAFT_VC870_SER, + }, { "Voltcraft", "VC-920 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1", 2400, UT71X_PACKET_SIZE, 0, 0, NULL, @@ -685,6 +693,7 @@ DRV(voltcraft_me42, VOLTCRAFT_ME42, "voltcraft-me42", "Voltcraft ME-42") DRV(voltcraft_vc820_ser, VOLTCRAFT_VC820_SER, "voltcraft-vc820-ser", "Voltcraft VC-820 (UT-D02 cable)") DRV(voltcraft_vc830_ser, VOLTCRAFT_VC830_SER, "voltcraft-vc830-ser", "Voltcraft VC-830 (UT-D02 cable)") DRV(voltcraft_vc840_ser, VOLTCRAFT_VC840_SER, "voltcraft-vc840-ser", "Voltcraft VC-840 (UT-D02 cable)") +DRV(voltcraft_vc870_ser, VOLTCRAFT_VC870_SER, "voltcraft-vc870-ser", "Voltcraft VC-870 (UT-D02 cable)") DRV(voltcraft_vc920_ser, VOLTCRAFT_VC920_SER, "voltcraft-vc920-ser", "Voltcraft VC-920 (UT-D02 cable)") DRV(voltcraft_vc940_ser, VOLTCRAFT_VC940_SER, "voltcraft-vc940-ser", "Voltcraft VC-940 (UT-D02 cable)") DRV(voltcraft_vc960_ser, VOLTCRAFT_VC960_SER, "voltcraft-vc960-ser", "Voltcraft VC-960 (UT-D02 cable)") diff --git a/src/hardware/serial-dmm/protocol.c b/src/hardware/serial-dmm/protocol.c index 64564ef4..bcac8500 100644 --- a/src/hardware/serial-dmm/protocol.c +++ b/src/hardware/serial-dmm/protocol.c @@ -29,10 +29,13 @@ static void log_dmm_packet(const uint8_t *buf) { - sr_dbg("DMM packet: %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x", + sr_dbg("DMM packet: %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], - buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13]); + buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], + buf[14], buf[15], buf[16], buf[17], buf[18], buf[19], buf[20], + buf[21], buf[22]); } static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, @@ -214,6 +217,7 @@ RECEIVE_DATA(VOLTCRAFT_ME42, metex14) RECEIVE_DATA(VOLTCRAFT_VC820_SER, fs9721) RECEIVE_DATA(VOLTCRAFT_VC830_SER, fs9922) RECEIVE_DATA(VOLTCRAFT_VC840_SER, fs9721) +RECEIVE_DATA(VOLTCRAFT_VC870_SER, vc870) RECEIVE_DATA(VOLTCRAFT_VC920_SER, ut71x) RECEIVE_DATA(VOLTCRAFT_VC940_SER, ut71x) RECEIVE_DATA(VOLTCRAFT_VC960_SER, ut71x) diff --git a/src/hardware/serial-dmm/protocol.h b/src/hardware/serial-dmm/protocol.h index a4e06ce8..33317fc6 100644 --- a/src/hardware/serial-dmm/protocol.h +++ b/src/hardware/serial-dmm/protocol.h @@ -47,6 +47,7 @@ enum { VOLTCRAFT_VC820_SER, VOLTCRAFT_VC830_SER, VOLTCRAFT_VC840_SER, + VOLTCRAFT_VC870_SER, VOLTCRAFT_VC920_SER, VOLTCRAFT_VC940_SER, VOLTCRAFT_VC960_SER, @@ -156,6 +157,7 @@ SR_PRIV int receive_data_VOLTCRAFT_ME42(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC820_SER(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC830_SER(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC840_SER(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_VOLTCRAFT_VC870_SER(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC920_SER(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC940_SER(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC960_SER(int fd, int revents, void *cb_data); diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index f7b8a941..fea68a76 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -54,6 +54,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut71e_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc830_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc840_driver_info; +SR_PRIV struct sr_dev_driver voltcraft_vc870_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc920_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc940_driver_info; SR_PRIV struct sr_dev_driver voltcraft_vc960_driver_info; @@ -177,6 +178,11 @@ SR_PRIV struct dmm_info udmms[] = { sr_fs9721_00_temp_c, &voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840, }, + { + "Voltcraft", "VC-870", 9600, VC870_PACKET_SIZE, + sr_vc870_packet_valid, sr_vc870_parse, NULL, + &voltcraft_vc870_driver_info, receive_data_VOLTCRAFT_VC870, + }, { "Voltcraft", "VC-920", 2400, UT71X_PACKET_SIZE, sr_ut71x_packet_valid, sr_ut71x_parse, NULL, @@ -468,6 +474,7 @@ DRV(uni_t_ut71e, UNI_T_UT71E, "uni-t-ut71e", "UNI-T UT71E") DRV(voltcraft_vc820, VOLTCRAFT_VC820, "voltcraft-vc820", "Voltcraft VC-820") DRV(voltcraft_vc830, VOLTCRAFT_VC830, "voltcraft-vc830", "Voltcraft VC-830") DRV(voltcraft_vc840, VOLTCRAFT_VC840, "voltcraft-vc840", "Voltcraft VC-840") +DRV(voltcraft_vc870, VOLTCRAFT_VC870, "voltcraft-vc870", "Voltcraft VC-870") DRV(voltcraft_vc920, VOLTCRAFT_VC920, "voltcraft-vc920", "Voltcraft VC-920") DRV(voltcraft_vc940, VOLTCRAFT_VC940, "voltcraft-vc940", "Voltcraft VC-940") DRV(voltcraft_vc960, VOLTCRAFT_VC960, "voltcraft-vc960", "Voltcraft VC-960") diff --git a/src/hardware/uni-t-dmm/protocol.c b/src/hardware/uni-t-dmm/protocol.c index 8355382f..28bfc096 100644 --- a/src/hardware/uni-t-dmm/protocol.c +++ b/src/hardware/uni-t-dmm/protocol.c @@ -319,6 +319,7 @@ RECEIVE_DATA(UNI_T_UT71E, ut71x) RECEIVE_DATA(VOLTCRAFT_VC820, fs9721) RECEIVE_DATA(VOLTCRAFT_VC830, fs9922) RECEIVE_DATA(VOLTCRAFT_VC840, fs9721) +RECEIVE_DATA(VOLTCRAFT_VC870, vc870) RECEIVE_DATA(VOLTCRAFT_VC920, ut71x) RECEIVE_DATA(VOLTCRAFT_VC940, ut71x) RECEIVE_DATA(VOLTCRAFT_VC960, ut71x) diff --git a/src/hardware/uni-t-dmm/protocol.h b/src/hardware/uni-t-dmm/protocol.h index 141414a7..b37408b0 100644 --- a/src/hardware/uni-t-dmm/protocol.h +++ b/src/hardware/uni-t-dmm/protocol.h @@ -47,6 +47,7 @@ enum { VOLTCRAFT_VC820, VOLTCRAFT_VC830, VOLTCRAFT_VC840, + VOLTCRAFT_VC870, VOLTCRAFT_VC920, VOLTCRAFT_VC940, VOLTCRAFT_VC960, @@ -111,6 +112,7 @@ SR_PRIV int receive_data_UNI_T_UT71E(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC820(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC830(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC840(int fd, int revents, void *cb_data); +SR_PRIV int receive_data_VOLTCRAFT_VC870(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC920(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC940(int fd, int revents, void *cb_data); SR_PRIV int receive_data_VOLTCRAFT_VC960(int fd, int revents, void *cb_data); diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index e6f2dbe2..6617e7ae 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -1072,6 +1072,27 @@ SR_PRIV gboolean sr_ut71x_packet_valid(const uint8_t *buf); SR_PRIV int sr_ut71x_parse(const uint8_t *buf, float *floatval, struct sr_datafeed_analog *analog, void *info); +/*--- hardware/dmm/vc870.c --------------------------------------------------*/ + +#define VC870_PACKET_SIZE 23 + +struct vc870_info { + gboolean is_voltage, is_dc, is_ac, is_temperature, is_resistance; + gboolean is_continuity, is_capacitance, is_diode, is_loop_current; + gboolean is_current, is_micro, is_milli, is_power; + gboolean is_power_factor_freq, is_power_apparent_power, is_v_a_eff_value; + gboolean is_sign2, is_sign1, is_batt, is_ol1, is_max, is_min; + gboolean is_maxmin, is_rel, is_ol2, is_open, is_manu, is_hold; + gboolean is_light, is_usb, is_warning, is_auto_power, is_misplug_warn; + gboolean is_lo, is_hi, is_open2; + + gboolean is_frequency, is_dual_display, is_auto, is_rms; +}; + +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); + /*--- hardware/lcr/es51919.c ------------------------------------------------*/ SR_PRIV void es51919_serial_clean(void *priv);