* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/*
+/**
+ * @file
+ *
* Metex 14-bytes ASCII protocol parser.
*
+ * @internal
* This should work for various multimeters which use this kind of protocol,
* even though there is some variation in which modes each DMM supports.
*
#define LOG_PREFIX "metex14"
-static int parse_value(const uint8_t *buf, float *result)
+/** Parse value from buf, byte 2-8. */
+static int parse_value(const uint8_t *buf, struct metex14_info *info,
+ float *result)
{
int i, is_ol, cnt;
char valstr[7 + 1];
return SR_OK;
}
+ /* Logic functions */
+ if (!strcmp((const char *)&valstr, "READY") ||
+ !strcmp((const char *)&valstr, "FLOAT")) {
+ *result = INFINITY;
+ info->is_logic = TRUE;
+ } else if (!strcmp((const char *)&valstr, "Hi")) {
+ *result = 1.0;
+ info->is_logic = TRUE;
+ } else if (!strcmp((const char *)&valstr, "Lo")) {
+ *result = 0.0;
+ info->is_logic = TRUE;
+ }
+ if (info->is_logic)
+ return SR_OK;
+
/* Bytes 2-8: Sign, value (up to 5 digits) and decimal point */
sscanf((const char *)&valstr, "%f", result);
char unit[4 + 1];
const char *u;
- /* Bytes 0-1: Measurement mode */
- /* Note: Protocol doesn't distinguish "resistance" from "beep" mode. */
- info->is_ac = !strncmp(buf, "AC", 2);
- info->is_dc = !strncmp(buf, "DC", 2);
- info->is_resistance = !strncmp(buf, "OH", 2);
- info->is_capacity = !strncmp(buf, "CA", 2);
- info->is_temperature = !strncmp(buf, "TE", 2);
- info->is_diode = !strncmp(buf, "DI", 2);
- info->is_frequency = !strncmp(buf, "FR", 2);
- info->is_gain = !strncmp(buf, "DB", 2);
- info->is_hfe = !strncmp(buf, "HF", 2);
-
- /*
- * Note: "DB" shows the logarithmic ratio of input voltage to a
- * pre-stored (user-changeable) value in the DMM.
- */
-
- if (info->is_dc || info->is_ac)
- info->is_volt = TRUE;
+ /* Bytes 0-1: Measurement mode AC, DC */
+ info->is_ac = !strncmp(buf, "AC", 2);
+ info->is_dc = !strncmp(buf, "DC", 2);
/* Bytes 2-8: See parse_value(). */
else if (!strcasecmp(u, ""))
info->is_unitless = TRUE;
+ /* Bytes 0-1: Measurement mode, except AC/DC */
+ info->is_resistance = !strncmp(buf, "OH", 2) ||
+ (!strncmp(buf, " ", 2) && info->is_ohm);
+ info->is_capacity = !strncmp(buf, "CA", 2) ||
+ (!strncmp(buf, " ", 2) && info->is_farad);
+ info->is_temperature = !strncmp(buf, "TE", 2);
+ info->is_diode = !strncmp(buf, "DI", 2) ||
+ (!strncmp(buf, " ", 2) && info->is_volt && info->is_milli);
+ info->is_frequency = !strncmp(buf, "FR", 2) ||
+ (!strncmp(buf, " ", 2) && info->is_hertz);
+ info->is_gain = !strncmp(buf, "DB", 2);
+ info->is_hfe = !strncmp(buf, "HF", 2) ||
+ (!strncmp(buf, " ", 2) && !info->is_volt && !info->is_ohm &&
+ !info->is_logic && !info->is_farad && !info->is_hertz);
+ /*
+ * Note:
+ * - Protocol doesn't distinguish "resistance" from "beep" mode.
+ * - "DB" shows the logarithmic ratio of input voltage to a
+ * pre-stored (user-changeable) value in the DMM.
+ */
+
/* Byte 13: Always '\r' (carriage return, 0x0d, 13) */
}
analog->mq = SR_MQ_GAIN;
analog->unit = SR_UNIT_UNITLESS;
}
+ if (info->is_logic) {
+ analog->mq = SR_MQ_GAIN;
+ analog->unit = SR_UNIT_UNITLESS;
+ }
/* Measurement related flags */
if (info->is_ac)
/* Don't print byte 13. That one contains the carriage return. */
sr_dbg("DMM packet: \"%.13s\"", buf);
- if ((ret = parse_value(buf, floatval)) != SR_OK) {
+ memset(info_local, 0x00, sizeof(struct metex14_info));
+
+ if ((ret = parse_value(buf, info_local, floatval)) != SR_OK) {
sr_dbg("Error parsing value: %d.", ret);
return ret;
}
- memset(info_local, 0x00, sizeof(struct metex14_info));
parse_flags((const char *)buf, info_local);
handle_flags(analog, floatval, info_local);
SR_PRIV struct sr_dev_driver radioshack_22_805_driver_info;
SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info;
SR_PRIV struct sr_dev_driver tecpel_dmm_8061_ser_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_m3650cr_driver_info;
SR_PRIV struct sr_dev_driver voltcraft_m3650d_driver_info;
SR_PRIV struct sr_dev_driver voltcraft_m4650cr_driver_info;
SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info;
&tecpel_dmm_8061_ser_driver_info,
receive_data_TECPEL_DMM_8061_SER,
},
+ {
+ "Voltcraft", "M-3650CR", "1200/7n2/rts=0/dtr=1", 1200,
+ METEX14_PACKET_SIZE, sr_metex14_packet_request,
+ sr_metex14_packet_valid, sr_metex14_parse,
+ NULL,
+ &voltcraft_m3650cr_driver_info, receive_data_VOLTCRAFT_M3650CR,
+ },
{
"Voltcraft", "M-3650D", "1200/7n2/rts=0/dtr=1", 1200,
METEX14_PACKET_SIZE, sr_metex14_packet_request,
DRV(radioshack_22_805, RADIOSHACK_22_805, "radioshack-22-805", "RadioShack 22-805")
DRV(radioshack_22_812, RADIOSHACK_22_812, "radioshack-22-812", "RadioShack 22-812")
DRV(tecpel_dmm_8061_ser, TECPEL_DMM_8061_SER, "tecpel-dmm-8061-ser", "Tecpel DMM-8061 (UT-D02 cable)")
+DRV(voltcraft_m3650cr, VOLTCRAFT_M3650CR, "voltcraft-m3650cr", "Voltcraft M-3650CR")
DRV(voltcraft_m3650d, VOLTCRAFT_M3650D, "voltcraft-m3650d", "Voltcraft M-3650D")
DRV(voltcraft_m4650cr, VOLTCRAFT_M4650CR, "voltcraft-m4650cr", "Voltcraft M-4650CR")
DRV(voltcraft_me42, VOLTCRAFT_ME42, "voltcraft-me42", "Voltcraft ME-42")
extern SR_PRIV struct sr_dev_driver radioshack_22_805_driver_info;
extern SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info;
extern SR_PRIV struct sr_dev_driver tecpel_dmm_8061_ser_driver_info;
+extern SR_PRIV struct sr_dev_driver voltcraft_m3650cr_driver_info;
extern SR_PRIV struct sr_dev_driver voltcraft_m3650d_driver_info;
extern SR_PRIV struct sr_dev_driver voltcraft_m4650cr_driver_info;
extern SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info;
#endif
#ifdef HAVE_HW_GMC_MH_1X_2X
&gmc_mh_1x_2x_rs232_driver_info,
- &gmc_mh_2x_bd232_driver_info,
+ &gmc_mh_2x_bd232_driver_info,
#endif
#ifdef HAVE_HW_HAMEG_HMO
&hameg_hmo_driver_info,
&radioshack_22_805_driver_info,
&radioshack_22_812_driver_info,
&tecpel_dmm_8061_ser_driver_info,
+ &voltcraft_m3650cr_driver_info,
&voltcraft_m3650d_driver_info,
&voltcraft_m4650cr_driver_info,
&voltcraft_me42_driver_info,