serial-dmm: Add PeakTech 2025 meter support.
[libsigrok.git] / src / hardware / serial-dmm / api.c
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
5  * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
6  * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #include <config.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <string.h>
27 #include <glib.h>
28 #include <libsigrok/libsigrok.h>
29 #include "libsigrok-internal.h"
30 #include "protocol.h"
31
32 static const uint32_t scanopts[] = {
33         SR_CONF_CONN,
34         SR_CONF_SERIALCOMM,
35 };
36
37 static const uint32_t drvopts[] = {
38         SR_CONF_MULTIMETER,
39 };
40
41 static const uint32_t devopts[] = {
42         SR_CONF_CONTINUOUS,
43         SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
44         SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
45 };
46
47 static GSList *scan(struct sr_dev_driver *di, GSList *options)
48 {
49         struct dmm_info *dmm;
50         struct sr_config *src;
51         GSList *l, *devices;
52         const char *conn, *serialcomm;
53         struct sr_dev_inst *sdi;
54         struct dev_context *devc;
55         struct sr_serial_dev_inst *serial;
56         int ret;
57         size_t dropped, len, packet_len;
58         uint8_t buf[128];
59         size_t ch_idx;
60         char ch_name[12];
61
62         dmm = (struct dmm_info *)di;
63
64         conn = dmm->conn;
65         serialcomm = dmm->serialcomm;
66         for (l = options; l; l = l->next) {
67                 src = l->data;
68                 switch (src->key) {
69                 case SR_CONF_CONN:
70                         conn = g_variant_get_string(src->data, NULL);
71                         break;
72                 case SR_CONF_SERIALCOMM:
73                         serialcomm = g_variant_get_string(src->data, NULL);
74                         break;
75                 }
76         }
77         if (!conn)
78                 return NULL;
79
80         serial = sr_serial_dev_inst_new(conn, serialcomm);
81
82         if (serial_open(serial, SERIAL_RDWR) != SR_OK)
83                 return NULL;
84         sr_info("Probing serial port %s.", conn);
85
86         if (dmm->after_open) {
87                 ret = dmm->after_open(serial);
88                 if (ret != SR_OK) {
89                         sr_err("Activity after port open failed: %d.", ret);
90                         return NULL;
91                 }
92         }
93
94         devices = NULL;
95
96         /* Request a packet if the DMM requires this. */
97         if (dmm->packet_request) {
98                 if ((ret = dmm->packet_request(serial)) < 0) {
99                         sr_err("Failed to request packet: %d.", ret);
100                         return NULL;
101                 }
102         }
103
104         /*
105          * There's no way to get an ID from the multimeter. It just sends data
106          * periodically (or upon request), so the best we can do is check if
107          * the packets match the expected format.
108          *
109          * If we dropped more than two packets worth of data, something is
110          * wrong. We shouldn't quit however, since the dropped bytes might be
111          * just zeroes at the beginning of the stream. Those can occur as a
112          * combination of the nonstandard cable that ships with some devices
113          * and the serial port or USB to serial adapter.
114          */
115         len = sizeof(buf);
116         ret = serial_stream_detect(serial, buf, &len, dmm->packet_size,
117                 dmm->packet_valid, dmm->packet_valid_len, &packet_len, 3000);
118         if (ret != SR_OK)
119                 goto scan_cleanup;
120         dropped = len - dmm->packet_size;
121         if (dropped > 2 * packet_len)
122                 sr_warn("Packet search dropped a lot of data.");
123         sr_info("Found device on port %s.", conn);
124
125         /*
126          * Setup optional additional callbacks when sub device drivers
127          * happen to provide them. (This is a compromise to do it here,
128          * and not extend the DMM_CONN() et al set of macros.)
129          */
130         if (strcmp(dmm->di.name, "brymen-bm52x") == 0) {
131                 /* Applicable to BM520s but not to BM820s. */
132                 dmm->dmm_state_init = brymen_bm52x_state_init;
133                 dmm->dmm_state_free = brymen_bm52x_state_free;
134                 dmm->config_get = brymen_bm52x_config_get;
135                 dmm->config_set = brymen_bm52x_config_set;
136                 dmm->config_list = brymen_bm52x_config_list;
137                 dmm->acquire_start = brymen_bm52x_acquire_start;
138         }
139         if (dmm->dmm_state_init)
140                 dmm->dmm_state = dmm->dmm_state_init();
141
142         /* Setup the device instance. */
143         sdi = g_malloc0(sizeof(*sdi));
144         sdi->status = SR_ST_INACTIVE;
145         sdi->vendor = g_strdup(dmm->vendor);
146         sdi->model = g_strdup(dmm->device);
147         devc = g_malloc0(sizeof(*devc));
148         sr_sw_limits_init(&devc->limits);
149         sdi->inst_type = SR_INST_SERIAL;
150         sdi->conn = serial;
151         sdi->priv = devc;
152
153         /* Create (optionally device dependent) channel(s). */
154         dmm->channel_count = 1;
155         if (dmm->packet_parse == sr_brymen_bm52x_parse)
156                 dmm->channel_count = BRYMEN_BM52X_DISPLAY_COUNT;
157         if (dmm->packet_parse == sr_brymen_bm86x_parse)
158                 dmm->channel_count = BRYMEN_BM86X_DISPLAY_COUNT;
159         if (dmm->packet_parse == sr_eev121gw_3displays_parse) {
160                 dmm->channel_count = EEV121GW_DISPLAY_COUNT;
161                 dmm->channel_formats = eev121gw_channel_formats;
162         }
163         if (dmm->packet_parse == sr_metex14_4packets_parse)
164                 dmm->channel_count = 4;
165         if (dmm->packet_parse == sr_ms2115b_parse) {
166                 dmm->channel_count = MS2115B_DISPLAY_COUNT;
167                 dmm->channel_formats = ms2115b_channel_formats;
168         }
169         for (ch_idx = 0; ch_idx < dmm->channel_count; ch_idx++) {
170                 size_t ch_num;
171                 const char *fmt;
172                 fmt = "P%zu";
173                 if (dmm->channel_formats && dmm->channel_formats[ch_idx])
174                         fmt = dmm->channel_formats[ch_idx];
175                 ch_num = ch_idx + 1;
176                 snprintf(ch_name, sizeof(ch_name), fmt, ch_num);
177                 sr_channel_new(sdi, ch_idx, SR_CHANNEL_ANALOG, TRUE, ch_name);
178         }
179
180         /* Add found device to result set. */
181         devices = g_slist_append(devices, sdi);
182
183 scan_cleanup:
184         serial_close(serial);
185
186         return std_scan_complete(di, devices);
187 }
188
189 static int config_get(uint32_t key, GVariant **data,
190         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
191 {
192         struct dev_context *devc;
193         struct dmm_info *dmm;
194
195         if (!sdi)
196                 return SR_ERR_ARG;
197         devc = sdi->priv;
198
199         switch (key) {
200         case SR_CONF_LIMIT_SAMPLES:
201         case SR_CONF_LIMIT_FRAMES:
202         case SR_CONF_LIMIT_MSEC:
203                 return sr_sw_limits_config_get(&devc->limits, key, data);
204         default:
205                 dmm = (struct dmm_info *)sdi->driver;
206                 if (!dmm || !dmm->config_get)
207                         return SR_ERR_NA;
208                 return dmm->config_get(dmm->dmm_state, key, data, sdi, cg);
209         }
210         /* UNREACH */
211 }
212
213 static int config_set(uint32_t key, GVariant *data,
214         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
215 {
216         struct dev_context *devc;
217         struct dmm_info *dmm;
218
219         if (!sdi)
220                 return SR_ERR_ARG;
221         devc = sdi->priv;
222         (void)cg;
223
224         switch (key) {
225         case SR_CONF_LIMIT_SAMPLES:
226         case SR_CONF_LIMIT_FRAMES:
227         case SR_CONF_LIMIT_MSEC:
228                 return sr_sw_limits_config_set(&devc->limits, key, data);
229         default:
230                 dmm = (struct dmm_info *)sdi->driver;
231                 if (!dmm || !dmm->config_set)
232                         return SR_ERR_NA;
233                 return dmm->config_set(dmm->dmm_state, key, data, sdi, cg);
234         }
235 }
236
237 static int config_list(uint32_t key, GVariant **data,
238         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
239 {
240         struct dmm_info *dmm;
241         int ret;
242
243         /* Use common logic for standard keys. */
244         if (!sdi)
245                 return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
246
247         /*
248          * Check for device specific config_list handler. ERR N/A from
249          * that handler is non-fatal, just falls back to common logic.
250          */
251         dmm = (struct dmm_info *)sdi->driver;
252         if (dmm && dmm->config_list) {
253                 ret = dmm->config_list(dmm->dmm_state, key, data, sdi, cg);
254                 if (ret != SR_ERR_NA)
255                         return ret;
256         }
257
258         return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
259 }
260
261 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
262 {
263         struct dev_context *devc;
264         struct dmm_info *dmm;
265         sr_receive_data_callback cb_func;
266         void *cb_data;
267         int ret;
268         struct sr_serial_dev_inst *serial;
269
270         devc = sdi->priv;
271
272         sr_sw_limits_acquisition_start(&devc->limits);
273         std_session_send_df_header(sdi);
274
275         cb_func = receive_data;
276         cb_data = (void *)sdi;
277         dmm = (struct dmm_info *)sdi->driver;
278         if (dmm && dmm->acquire_start) {
279                 ret = dmm->acquire_start(dmm->dmm_state, sdi,
280                         &cb_func, &cb_data);
281                 if (ret < 0)
282                         return ret;
283         }
284
285         serial = sdi->conn;
286         serial_source_add(sdi->session, serial, G_IO_IN, 50,
287                 cb_func, cb_data);
288
289         return SR_OK;
290 }
291
292 #define DMM_ENTRY(ID, CHIPSET, VENDOR, MODEL, \
293                 CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
294                 OPEN, REQUEST, VALID, PARSE, DETAILS, \
295                 INIT_STATE, FREE_STATE, VALID_LEN, PARSE_LEN, \
296                 CFG_GET, CFG_SET, CFG_LIST, ACQ_START) \
297         &((struct dmm_info) { \
298                 { \
299                         .name = ID, \
300                         .longname = VENDOR " " MODEL, \
301                         .api_version = 1, \
302                         .init = std_init, \
303                         .cleanup = std_cleanup, \
304                         .scan = scan, \
305                         .dev_list = std_dev_list, \
306                         .dev_clear = std_dev_clear, \
307                         .config_get = config_get, \
308                         .config_set = config_set, \
309                         .config_list = config_list, \
310                         .dev_open = std_serial_dev_open, \
311                         .dev_close = std_serial_dev_close, \
312                         .dev_acquisition_start = dev_acquisition_start, \
313                         .dev_acquisition_stop = std_serial_dev_acquisition_stop, \
314                         .context = NULL, \
315                 }, \
316                 VENDOR, MODEL, CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
317                 REQUEST, 1, NULL, VALID, PARSE, DETAILS, \
318                 sizeof(struct CHIPSET##_info), \
319                 NULL, INIT_STATE, FREE_STATE, \
320                 OPEN, VALID_LEN, PARSE_LEN, \
321                 CFG_GET, CFG_SET, CFG_LIST, ACQ_START, \
322         }).di
323
324 #define DMM_CONN(ID, CHIPSET, VENDOR, MODEL, \
325                 CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
326                 REQUEST, VALID, PARSE, DETAILS) \
327         DMM_ENTRY(ID, CHIPSET, VENDOR, MODEL, \
328                 CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
329                 NULL, REQUEST, VALID, PARSE, DETAILS, \
330                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
331
332 #define DMM(ID, CHIPSET, VENDOR, MODEL, SERIALCOMM, PACKETSIZE, TIMEOUT, \
333                 DELAY, REQUEST, VALID, PARSE, DETAILS) \
334         DMM_CONN(ID, CHIPSET, VENDOR, MODEL, \
335                 NULL, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
336                 REQUEST, VALID, PARSE, DETAILS)
337
338 #define DMM_LEN(ID, CHIPSET, VENDOR, MODEL, \
339                 CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
340                 INIT, FREE, OPEN, REQUEST, VALID, PARSE, DETAILS) \
341         DMM_ENTRY(ID, CHIPSET, VENDOR, MODEL, \
342                 CONN, SERIALCOMM, PACKETSIZE, TIMEOUT, DELAY, \
343                 OPEN, REQUEST, NULL, NULL, DETAILS, \
344                 INIT, FREE, VALID, PARSE, NULL, NULL, NULL, NULL)
345
346 SR_REGISTER_DEV_DRIVER_LIST(serial_dmm_drivers,
347         /*
348          * The items are sorted by chipset first and then model name.
349          *
350          * This reflects the developer's perspective and is preferrable
351          * during maintenance, as a vendor/product based sort order does
352          * not work well for rebranded models, and from a support point
353          * of view it's more important to identify similarities between
354          * models and compatible devices.
355          *
356          * Fold marks {{{ }}} with matching braces were added, to further
357          * speed up navigation in the long list.
358          */
359         /* asycii based meters {{{ */
360         DMM(
361                 "metrix-mx56c", asycii, "Metrix", "MX56C",
362                 "2400/8n1", ASYCII_PACKET_SIZE, 0, 0, NULL,
363                 sr_asycii_packet_valid, sr_asycii_parse, NULL
364         ),
365         /* }}} */
366         /* bm25x based meters {{{ */
367         DMM(
368                 "brymen-bm25x", bm25x,
369                 "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1",
370                 BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL,
371                 sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse,
372                 NULL
373         ),
374         /* }}} */
375         /* bm52x based meters {{{ */
376         DMM_CONN(
377                 "brymen-bm52x", brymen_bm52x, "Brymen", "BM52x",
378                 "hid/bu86x", NULL, BRYMEN_BM52X_PACKET_SIZE, 4000, 500,
379                 sr_brymen_bm52x_packet_request,
380                 sr_brymen_bm52x_packet_valid, sr_brymen_bm52x_parse,
381                 NULL
382         ),
383         DMM_CONN(
384                 "brymen-bm82x", brymen_bm52x, "Brymen", "BM82x",
385                 "hid/bu86x", NULL, BRYMEN_BM52X_PACKET_SIZE, 4000, 500,
386                 sr_brymen_bm82x_packet_request,
387                 sr_brymen_bm82x_packet_valid, sr_brymen_bm52x_parse,
388                 NULL
389         ),
390         /* }}} */
391         /* bm85x based meters {{{ */
392         DMM_LEN(
393                 "brymen-bm85x", brymen_bm85x, "Brymen", "BM85x",
394                 NULL, "9600/8n1/dtr=1/rts=1",
395                 BRYMEN_BM85x_PACKET_SIZE_MIN, 2000, 400,
396                 NULL, NULL, /* INIT/FREE for DMM state */
397                 brymen_bm85x_after_open, brymen_bm85x_packet_request,
398                 brymen_bm85x_packet_valid, brymen_bm85x_parse,
399                 NULL
400         ),
401         /* }}} */
402         /* bm86x based meters {{{ */
403         DMM_CONN(
404                 "brymen-bm86x", brymen_bm86x, "Brymen", "BM86x",
405                 "hid/bu86x", NULL, BRYMEN_BM86X_PACKET_SIZE, 500, 100,
406                 sr_brymen_bm86x_packet_request,
407                 sr_brymen_bm86x_packet_valid, sr_brymen_bm86x_parse,
408                 NULL
409         ),
410         /* }}} */
411         /* dtm0660 based meters {{{ */
412         DMM(
413                 "peaktech-3415", dtm0660,
414                 "PeakTech", "3415", "2400/8n1/rts=0/dtr=1",
415                 DTM0660_PACKET_SIZE, 0, 0, NULL,
416                 sr_dtm0660_packet_valid, sr_dtm0660_parse, NULL
417         ),
418         DMM(
419                 "velleman-dvm4100", dtm0660,
420                 "Velleman", "DVM4100", "2400/8n1/rts=0/dtr=1",
421                 DTM0660_PACKET_SIZE, 0, 0, NULL,
422                 sr_dtm0660_packet_valid, sr_dtm0660_parse, NULL
423         ),
424         /* }}} */
425         /* eev121gw based meters {{{ */
426         DMM(
427                 "eevblog-121gw", eev121gw, "EEVblog", "121GW",
428                 "115200/8n1", EEV121GW_PACKET_SIZE, 0, 0, NULL,
429                 sr_eev121gw_packet_valid, sr_eev121gw_3displays_parse, NULL
430         ),
431         /* }}} */
432         /* es519xx based meters {{{ */
433         DMM(
434                 "iso-tech-idm103n", es519xx,
435                 "ISO-TECH", "IDM103N", "2400/7o1/rts=0/dtr=1",
436                 ES519XX_11B_PACKET_SIZE, 0, 0, NULL,
437                 sr_es519xx_2400_11b_packet_valid, sr_es519xx_2400_11b_parse,
438                 NULL
439         ),
440         /*
441          * Note: ES51922 and ES51986 baudrate is actually 19230. This is
442          * "out" by .15%, and so is well within the typical 1% margin
443          * that is considered acceptable in UART communication, and thus
444          * should not cause an issue.
445          *
446          * However, using 19230 as baudrate here will not work, as most DMM
447          * cables do not support that baudrate!
448          */
449         DMM(
450                 "tenma-72-7750-ser", es519xx,
451                 "Tenma", "72-7750 (UT-D02 cable)", "19200/7o1/rts=0/dtr=1",
452                 ES519XX_11B_PACKET_SIZE, 0, 0, NULL,
453                 sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse,
454                 NULL
455         ),
456         DMM(
457                 "uni-t-ut60g-ser", es519xx,
458                 "UNI-T", "UT60G (UT-D02 cable)", "19200/7o1/rts=0/dtr=1",
459                 ES519XX_11B_PACKET_SIZE, 0, 0, NULL,
460                 sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse,
461                 NULL
462         ),
463         DMM(
464                 "uni-t-ut61e-ser", es519xx,
465                 "UNI-T", "UT61E (UT-D02 cable)", "19200/7o1/rts=0/dtr=1",
466                 ES519XX_14B_PACKET_SIZE, 0, 0, NULL,
467                 sr_es519xx_19200_14b_packet_valid, sr_es519xx_19200_14b_parse,
468                 NULL
469         ),
470         /* }}} */
471         /* fs9721 based meters {{{ */
472         DMM(
473                 "digitek-dt4000zc", fs9721,
474                 "Digitek", "DT4000ZC", "2400/8n1/dtr=1",
475                 FS9721_PACKET_SIZE, 0, 0, NULL,
476                 sr_fs9721_packet_valid, sr_fs9721_parse,
477                 sr_fs9721_10_temp_c
478         ),
479         DMM(
480                 "mastech-ms8250b", fs9721,
481                 "MASTECH", "MS8250B", "2400/8n1/rts=0/dtr=1",
482                 FS9721_PACKET_SIZE, 0, 0, NULL,
483                 sr_fs9721_packet_valid, sr_fs9721_parse,
484                 NULL
485         ),
486         DMM(
487                 "pce-pce-dm32", fs9721,
488                 "PCE", "PCE-DM32", "2400/8n1",
489                 FS9721_PACKET_SIZE, 0, 0, NULL,
490                 sr_fs9721_packet_valid, sr_fs9721_parse,
491                 sr_fs9721_01_10_temp_f_c
492         ),
493         DMM(
494                 "peaktech-3330", fs9721,
495                 "PeakTech", "3330", "2400/8n1/dtr=1",
496                 FS9721_PACKET_SIZE, 0, 0, NULL,
497                 sr_fs9721_packet_valid, sr_fs9721_parse,
498                 sr_fs9721_01_10_temp_f_c
499         ),
500         DMM(
501                 "tecpel-dmm-8061-ser", fs9721,
502                 "Tecpel", "DMM-8061 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
503                 FS9721_PACKET_SIZE, 0, 0, NULL,
504                 sr_fs9721_packet_valid, sr_fs9721_parse,
505                 sr_fs9721_00_temp_c
506         ),
507         DMM(
508                 "tekpower-tp4000ZC", fs9721,
509                 "TekPower", "TP4000ZC", "2400/8n1/dtr=1",
510                 FS9721_PACKET_SIZE, 0, 0, NULL,
511                 sr_fs9721_packet_valid, sr_fs9721_parse,
512                 sr_fs9721_10_temp_c
513         ),
514         DMM(
515                 "tenma-72-7745-ser", fs9721,
516                 "Tenma", "72-7745 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
517                 FS9721_PACKET_SIZE, 0, 0, NULL,
518                 sr_fs9721_packet_valid, sr_fs9721_parse,
519                 sr_fs9721_00_temp_c
520         ),
521         DMM(
522                 "uni-t-ut60a-ser", fs9721,
523                 "UNI-T", "UT60A (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
524                 FS9721_PACKET_SIZE, 0, 0, NULL,
525                 sr_fs9721_packet_valid, sr_fs9721_parse,
526                 NULL
527         ),
528         DMM(
529                 "uni-t-ut60e-ser", fs9721,
530                 "UNI-T", "UT60E (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
531                 FS9721_PACKET_SIZE, 0, 0, NULL,
532                 sr_fs9721_packet_valid, sr_fs9721_parse,
533                 sr_fs9721_00_temp_c
534         ),
535         DMM(
536                 "va-va18b", fs9721,
537                 "V&A", "VA18B", "2400/8n1",
538                 FS9721_PACKET_SIZE, 0, 0, NULL,
539                 sr_fs9721_packet_valid, sr_fs9721_parse,
540                 sr_fs9721_01_temp_c
541         ),
542         DMM(
543                 "va-va40b", fs9721,
544                 "V&A", "VA40B", "2400/8n1",
545                 FS9721_PACKET_SIZE, 0, 0, NULL,
546                 sr_fs9721_packet_valid, sr_fs9721_parse,
547                 sr_fs9721_max_c_min
548         ),
549         DMM(
550                 "voltcraft-vc820-ser", fs9721,
551                 "Voltcraft", "VC-820 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
552                 FS9721_PACKET_SIZE, 0, 0, NULL,
553                 sr_fs9721_packet_valid, sr_fs9721_parse,
554                 NULL
555         ),
556         DMM(
557                 "voltcraft-vc840-ser", fs9721,
558                 "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
559                 FS9721_PACKET_SIZE, 0, 0, NULL,
560                 sr_fs9721_packet_valid, sr_fs9721_parse,
561                 sr_fs9721_00_temp_c
562         ),
563         /* }}} */
564         /* fs9922 based meters {{{ */
565         DMM(
566                 "gwinstek-gdm-397", fs9922,
567                 "GW Instek", "GDM-397", "2400/8n1/rts=0/dtr=1",
568                 FS9922_PACKET_SIZE, 0, 0, NULL,
569                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
570         ),
571         DMM(
572                 "peaktech-2025", fs9922,
573                 "PeakTech", "2025", "2400/8n1/rts=0/dtr=1",
574                 FS9922_PACKET_SIZE, 0, 0, NULL,
575                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
576         ),
577         DMM(
578                 "sparkfun-70c", fs9922,
579                 "SparkFun", "70C", "2400/8n1/rts=0/dtr=1",
580                 FS9922_PACKET_SIZE, 0, 0, NULL,
581                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
582         ),
583         DMM(
584                 "uni-t-ut61b-ser", fs9922,
585                 "UNI-T", "UT61B (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
586                 FS9922_PACKET_SIZE, 0, 0, NULL,
587                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
588         ),
589         DMM(
590                 "uni-t-ut61c-ser", fs9922,
591                 "UNI-T", "UT61C (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
592                 FS9922_PACKET_SIZE, 0, 0, NULL,
593                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
594         ),
595         DMM(
596                 "uni-t-ut61d-ser", fs9922,
597                 "UNI-T", "UT61D (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
598                 FS9922_PACKET_SIZE, 0, 0, NULL,
599                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
600         ),
601         DMM_CONN(
602                 "victor-dmm", fs9922, "Victor", "Victor DMMs",
603                 "hid/victor", "2400/8n1", FS9922_PACKET_SIZE, 0, 0, NULL,
604                 sr_fs9922_packet_valid, sr_fs9922_parse, NULL
605         ),
606         DMM(
607                 /*
608                  * Note: The VC830 doesn't set the 'volt' and 'diode' bits of
609                  * the FS9922 protocol. Instead, it only sets the user-defined
610                  * bit "z1" to indicate "diode mode" and "voltage".
611                  */
612                 "voltcraft-vc830-ser", fs9922,
613                 "Voltcraft", "VC-830 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
614                 FS9922_PACKET_SIZE, 0, 0, NULL,
615                 sr_fs9922_packet_valid, sr_fs9922_parse,
616                 &sr_fs9922_z1_diode
617         ),
618         /* }}} */
619         /* m2110 based meters {{{ */
620         DMM(
621                 "bbcgm-2010", m2110,
622                 "BBC Goertz Metrawatt", "M2110", "1200/7n2",
623                 BBCGM_M2110_PACKET_SIZE, 0, 0, NULL,
624                 sr_m2110_packet_valid, sr_m2110_parse,
625                 NULL
626         ),
627         /* }}} */
628         /* meterman_38xr based meters {{{ */
629         DMM(
630                 "meterman-38xr", meterman_38xr,
631                 "Meterman", "38XR", "9600/8n1/rts=0/dtr=1",
632                 METERMAN_38XR_PACKET_SIZE, 0, 0, NULL,
633                 meterman_38xr_packet_valid, meterman_38xr_parse,
634                 NULL
635         ),
636         /* }}} */
637         /* metex14 based meters {{{ */
638         DMM(
639                 "mastech-mas345", metex14,
640                 "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1",
641                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
642                 sr_metex14_packet_valid, sr_metex14_parse,
643                 NULL
644         ),
645         DMM(
646                 "metex-m3640d", metex14,
647                 "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1",
648                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
649                 sr_metex14_packet_valid, sr_metex14_parse,
650                 NULL
651         ),
652         DMM(
653                 "metex-m3860m", metex14,
654                 "Metex", "M-3860M", "9600/7n2/rts=0/dtr=1",
655                 4 * METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
656                 sr_metex14_4packets_valid, sr_metex14_4packets_parse,
657                 NULL
658         ),
659         DMM(
660                 "metex-m4650cr", metex14,
661                 "Metex", "M-4650CR", "1200/7n2/rts=0/dtr=1",
662                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
663                 sr_metex14_packet_valid, sr_metex14_parse,
664                 NULL
665         ),
666         DMM(
667                 "metex-me21", metex14,
668                 "Metex", "ME-21", "2400/7n2/rts=0/dtr=1",
669                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
670                 sr_metex14_packet_valid, sr_metex14_parse,
671                 NULL
672         ),
673         DMM(
674                 "metex-me31", metex14,
675                 "Metex", "ME-31", "600/7n2/rts=0/dtr=1",
676                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
677                 sr_metex14_packet_valid, sr_metex14_parse,
678                 NULL
679         ),
680         DMM(
681                 "peaktech-3410", metex14,
682                 "PeakTech", "3410", "600/7n2/rts=0/dtr=1",
683                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
684                 sr_metex14_packet_valid, sr_metex14_parse,
685                 NULL
686         ),
687         DMM(
688                 "peaktech-4370", metex14,
689                 "PeakTech", "4370", "1200/7n2/rts=0/dtr=1",
690                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
691                 sr_metex14_packet_valid, sr_metex14_parse,
692                 NULL
693         ),
694         DMM(
695                 "peaktech-4390a", metex14,
696                 "PeakTech", "4390A", "9600/7n2/rts=0/dtr=1",
697                 4 * METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
698                 sr_metex14_4packets_valid, sr_metex14_4packets_parse,
699                 NULL
700         ),
701         DMM(
702                 "radioshack-22-168", metex14,
703                 "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1",
704                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
705                 sr_metex14_packet_valid, sr_metex14_parse,
706                 NULL
707         ),
708         DMM(
709                 "radioshack-22-805", metex14,
710                 "RadioShack", "22-805", "600/7n2/rts=0/dtr=1",
711                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
712                 sr_metex14_packet_valid, sr_metex14_parse,
713                 NULL
714         ),
715         DMM(
716                 "voltcraft-m3650cr", metex14,
717                 "Voltcraft", "M-3650CR", "1200/7n2/rts=0/dtr=1",
718                 METEX14_PACKET_SIZE, 150, 20, sr_metex14_packet_request,
719                 sr_metex14_packet_valid, sr_metex14_parse,
720                 NULL
721         ),
722         DMM(
723                 "voltcraft-m3650d", metex14,
724                 "Voltcraft", "M-3650D", "1200/7n2/rts=0/dtr=1",
725                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
726                 sr_metex14_packet_valid, sr_metex14_parse,
727                 NULL
728         ),
729         DMM(
730                 "voltcraft-m4650cr", metex14,
731                 "Voltcraft", "M-4650CR", "1200/7n2/rts=0/dtr=1",
732                 METEX14_PACKET_SIZE, 0, 0, sr_metex14_packet_request,
733                 sr_metex14_packet_valid, sr_metex14_parse,
734                 NULL
735         ),
736         DMM(
737                 "voltcraft-me42", metex14,
738                 "Voltcraft", "ME-42", "600/7n2/rts=0/dtr=1",
739                 METEX14_PACKET_SIZE, 250, 60, sr_metex14_packet_request,
740                 sr_metex14_packet_valid, sr_metex14_parse,
741                 NULL
742         ),
743         /* }}} */
744         /* ms2115b based meters {{{ */
745         DMM(
746                 "mastech-ms2115b", ms2115b,
747                 "MASTECH", "MS2115B", "1200/8n1",
748                 MS2115B_PACKET_SIZE, 0, 0, NULL,
749                 sr_ms2115b_packet_valid, sr_ms2115b_parse,
750                 NULL
751         ),
752         /* }}} */
753         /* ms8250d based meters {{{ */
754         DMM(
755                 "mastech-ms8250d", ms8250d,
756                 "MASTECH", "MS8250D", "2400/8n1/rts=0/dtr=1",
757                 MS8250D_PACKET_SIZE, 0, 0, NULL,
758                 sr_ms8250d_packet_valid, sr_ms8250d_parse,
759                 NULL
760         ),
761         /* }}} */
762         /* rs9lcd based meters {{{ */
763         DMM(
764                 "radioshack-22-812", rs9lcd,
765                 "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1",
766                 RS9LCD_PACKET_SIZE, 0, 0, NULL,
767                 sr_rs9lcd_packet_valid, sr_rs9lcd_parse,
768                 NULL
769         ),
770         /* }}} */
771         /* ut71x based meters {{{ */
772         DMM(
773                 "tenma-72-7730-ser", ut71x,
774                 "Tenma", "72-7730 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
775                 UT71X_PACKET_SIZE, 0, 0, NULL,
776                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
777         ),
778         DMM(
779                 "tenma-72-7732-ser", ut71x,
780                 "Tenma", "72-7732 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
781                 UT71X_PACKET_SIZE, 0, 0, NULL,
782                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
783         ),
784         DMM(
785                 "tenma-72-9380a-ser", ut71x,
786                 "Tenma", "72-9380A (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
787                 UT71X_PACKET_SIZE, 0, 0, NULL,
788                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
789         ),
790         DMM(
791                 "uni-t-ut71a-ser", ut71x,
792                 "UNI-T", "UT71A (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
793                 UT71X_PACKET_SIZE, 0, 0, NULL,
794                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
795         ),
796         DMM(
797                 "uni-t-ut71b-ser", ut71x,
798                 "UNI-T", "UT71B (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
799                 UT71X_PACKET_SIZE, 0, 0, NULL,
800                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
801         ),
802         DMM(
803                 "uni-t-ut71c-ser", ut71x,
804                 "UNI-T", "UT71C (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
805                 UT71X_PACKET_SIZE, 0, 0, NULL,
806                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
807         ),
808         DMM(
809                 "uni-t-ut71d-ser", ut71x,
810                 "UNI-T", "UT71D (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
811                 UT71X_PACKET_SIZE, 0, 0, NULL,
812                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
813         ),
814         DMM(
815                 "uni-t-ut71e-ser", ut71x,
816                 "UNI-T", "UT71E (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
817                 UT71X_PACKET_SIZE, 0, 0, NULL,
818                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
819         ),
820         DMM(
821                 "uni-t-ut804-ser", ut71x,
822                 "UNI-T", "UT804", "2400/7o1/rts=0/dtr=1",
823                 UT71X_PACKET_SIZE, 0, 0, NULL,
824                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
825         ),
826         DMM(
827                 "voltcraft-vc920-ser", ut71x,
828                 "Voltcraft", "VC-920 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
829                 UT71X_PACKET_SIZE, 0, 0, NULL,
830                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
831         ),
832         DMM(
833                 "voltcraft-vc940-ser", ut71x,
834                 "Voltcraft", "VC-940 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
835                 UT71X_PACKET_SIZE, 0, 0, NULL,
836                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
837         ),
838         DMM(
839                 "voltcraft-vc960-ser", ut71x,
840                 "Voltcraft", "VC-960 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
841                 UT71X_PACKET_SIZE, 0, 0, NULL,
842                 sr_ut71x_packet_valid, sr_ut71x_parse, NULL
843         ),
844         /* }}} */
845         /* vc870 based meters {{{ */
846         DMM(
847                 "voltcraft-vc870-ser", vc870,
848                 "Voltcraft", "VC-870 (UT-D02 cable)", "9600/8n1/rts=0/dtr=1",
849                 VC870_PACKET_SIZE, 0, 0, NULL,
850                 sr_vc870_packet_valid, sr_vc870_parse, NULL
851         ),
852         /* }}} */
853         /* vc96 based meters {{{ */
854         DMM(
855                 "voltcraft-vc96", vc96,
856                 "Voltcraft", "VC-96", "1200/8n2",
857                 VC96_PACKET_SIZE, 0, 0, NULL,
858                 sr_vc96_packet_valid, sr_vc96_parse,
859                 NULL
860         ),
861         /* }}} */
862         /*
863          * The list is sorted. Add new items in the respective chip's group.
864          */
865 );