serial-dmm: Take a dmm_info* instead of an index in dmms[]
[sigrok:libsigrok.git] / hardware / serial-dmm / api.c
1 /*
2  * This file is part of the sigrok 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 <glib.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26 #include <string.h>
27 #include <errno.h>
28 #include "libsigrok.h"
29 #include "libsigrok-internal.h"
30 #include "protocol.h"
31
32 static const int hwopts[] = {
33         SR_HWOPT_CONN,
34         SR_HWOPT_SERIALCOMM,
35         0,
36 };
37
38 static const int hwcaps[] = {
39         SR_HWCAP_MULTIMETER,
40         SR_HWCAP_LIMIT_SAMPLES,
41         SR_HWCAP_CONTINUOUS,
42         0,
43 };
44
45 static const char *probe_names[] = {
46         "Probe",
47         NULL,
48 };
49
50 SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info;
51 SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info;
52 SR_PRIV struct sr_dev_driver metex_me31_driver_info;
53 SR_PRIV struct sr_dev_driver peaktech_3410_driver_info;
54 SR_PRIV struct sr_dev_driver mastech_mas345_driver_info;
55 SR_PRIV struct sr_dev_driver va_va18b_driver_info;
56 SR_PRIV struct sr_dev_driver metex_m3640d_driver_info;
57 SR_PRIV struct sr_dev_driver peaktech_4370_driver_info;
58 SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info;
59 SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info;
60 SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info;
61
62 /* After hw_init() this will point to a device-specific entry (see above). */
63 static struct sr_dev_driver *fixme_di = NULL;
64
65 SR_PRIV struct dmm_info dmms[] = {
66         {
67                 "Digitek", "DT4000ZC", "2400/8n1", 2400,
68                 FS9721_PACKET_SIZE, NULL,
69                 sr_fs9721_packet_valid, sr_fs9721_parse,
70                 dmm_details_dt4000zc,
71                 &digitek_dt4000zc_driver_info, digitek_dt4000zc_receive_data,
72         },
73         {
74                 "TekPower", "TP4000ZC", "2400/8n1", 2400,
75                 FS9721_PACKET_SIZE, NULL,
76                 sr_fs9721_packet_valid, sr_fs9721_parse,
77                 dmm_details_tp4000zc,
78                 &tekpower_tp4000zc_driver_info, tekpower_tp4000zc_receive_data,
79         },
80         {
81                 "Metex", "ME-31", "600/7n2/rts=0/dtr=1", 600,
82                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
83                 sr_metex14_packet_valid, sr_metex14_parse,
84                 NULL,
85                 &metex_me31_driver_info, metex_me31_receive_data,
86         },
87         {
88                 "Peaktech", "3410", "600/7n2/rts=0/dtr=1", 600,
89                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
90                 sr_metex14_packet_valid, sr_metex14_parse,
91                 NULL,
92                 &peaktech_3410_driver_info, peaktech_3410_receive_data,
93         },
94         {
95                 "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1", 600,
96                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
97                 sr_metex14_packet_valid, sr_metex14_parse,
98                 NULL,
99                 &mastech_mas345_driver_info, mastech_mas345_receive_data,
100         },
101         {
102                 "V&A", "VA18B", "2400/8n1", 2400,
103                 FS9721_PACKET_SIZE, NULL,
104                 sr_fs9721_packet_valid, sr_fs9721_parse,
105                 dmm_details_va18b,
106                 &va_va18b_driver_info, va_va18b_receive_data,
107         },
108         {
109                 "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1", 1200,
110                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
111                 sr_metex14_packet_valid, sr_metex14_parse,
112                 NULL,
113                 &metex_m3640d_driver_info, metex_m3640d_receive_data,
114         },
115         {
116                 "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200,
117                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
118                 sr_metex14_packet_valid, sr_metex14_parse,
119                 NULL,
120                 &peaktech_4370_driver_info, peaktech_4370_receive_data,
121         },
122         {
123                 "PCE", "PCE-DM32", "2400/8n1", 2400,
124                 FS9721_PACKET_SIZE, NULL,
125                 sr_fs9721_packet_valid, sr_fs9721_parse,
126                 dmm_details_pce_dm32,
127                 &pce_pce_dm32_driver_info, pce_pce_dm32_receive_data,
128         },
129         {
130                 "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1", 1200,
131                 METEX14_PACKET_SIZE, sr_metex14_packet_request,
132                 sr_metex14_packet_valid, sr_metex14_parse,
133                 NULL,
134                 &radioshack_22_168_driver_info, radioshack_22_168_receive_data,
135         },
136         {
137                 "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1", 4800,
138                 RS9LCD_PACKET_SIZE, NULL,
139                 sr_rs9lcd_packet_valid, sr_rs9lcd_parse,
140                 NULL,
141                 &radioshack_22_812_driver_info, radioshack_22_812_receive_data,
142         },
143 };
144
145 /* Properly close and free all devices. */
146 static int clear_instances(void)
147 {
148         struct sr_dev_inst *sdi;
149         struct drv_context *drvc;
150         struct dev_context *devc;
151         GSList *l;
152
153         /* di is not necessarily initialized */
154         if (!fixme_di)
155                 return SR_OK;
156
157         if (!(drvc = fixme_di->priv))
158                 return SR_OK;
159
160         drvc = fixme_di->priv;
161         for (l = drvc->instances; l; l = l->next) {
162                 if (!(sdi = l->data))
163                         continue;
164                 if (!(devc = sdi->priv))
165                         continue;
166                 sr_serial_dev_inst_free(devc->serial);
167                 sr_dev_inst_free(sdi);
168         }
169         g_slist_free(drvc->instances);
170         drvc->instances = NULL;
171
172         return SR_OK;
173 }
174
175 static int hw_init(struct sr_context *sr_ctx, struct dmm_info *dmm)
176 {
177         struct drv_context *drvc;
178
179         if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
180                 sr_err("Driver context malloc failed.");
181                 return SR_ERR_MALLOC;
182         }
183
184         fixme_di = dmm->di;
185
186         sr_dbg("Selected '%s' subdriver.", dmm->di->name);
187
188         drvc->sr_ctx = sr_ctx;
189         fixme_di->priv = drvc;
190
191         return SR_OK;
192 }
193
194 static int hw_init_digitek_dt4000zc(struct sr_context *sr_ctx)
195 {
196         return hw_init(sr_ctx, &dmms[DIGITEK_DT4000ZC]);
197 }
198
199 static int hw_init_tekpower_tp4000zc(struct sr_context *sr_ctx)
200 {
201         return hw_init(sr_ctx, &dmms[TEKPOWER_TP4000ZC]);
202 }
203
204 static int hw_init_metex_me31(struct sr_context *sr_ctx)
205 {
206         return hw_init(sr_ctx, &dmms[METEX_ME31]);
207 }
208
209 static int hw_init_peaktech_3410(struct sr_context *sr_ctx)
210 {
211         return hw_init(sr_ctx, &dmms[PEAKTECH_3410]);
212 }
213
214 static int hw_init_mastech_mas345(struct sr_context *sr_ctx)
215 {
216         return hw_init(sr_ctx, &dmms[MASTECH_MAS345]);
217 }
218
219 static int hw_init_va_va18b(struct sr_context *sr_ctx)
220 {
221         return hw_init(sr_ctx, &dmms[VA_VA18B]);
222 }
223
224 static int hw_init_metex_m3640d(struct sr_context *sr_ctx)
225 {
226         return hw_init(sr_ctx, &dmms[METEX_M3640D]);
227 }
228
229 static int hw_init_peaktech_4370(struct sr_context *sr_ctx)
230 {
231         return hw_init(sr_ctx, &dmms[PEAKTECH_4370]);
232 }
233
234 static int hw_init_pce_pce_dm32(struct sr_context *sr_ctx)
235 {
236         return hw_init(sr_ctx, &dmms[PCE_PCE_DM32]);
237 }
238
239 static int hw_init_radioshack_22_168(struct sr_context *sr_ctx)
240 {
241         return hw_init(sr_ctx, &dmms[RADIOSHACK_22_168]);
242 }
243
244 static int hw_init_radioshack_22_812(struct sr_context *sr_ctx)
245 {
246         return hw_init(sr_ctx, &dmms[RADIOSHACK_22_812]);
247 }
248
249 static GSList *scan(const char *conn, const char *serialcomm,
250                     struct dmm_info *dmm)
251 {
252         struct sr_dev_inst *sdi;
253         struct drv_context *drvc;
254         struct dev_context *devc;
255         struct sr_probe *probe;
256         struct sr_serial_dev_inst *serial;
257         GSList *devices;
258         int dropped, ret;
259         size_t len;
260         uint8_t buf[128];
261
262         if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
263                 return NULL;
264
265         if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
266                 return NULL;
267
268         sr_info("Probing port %s.", conn);
269
270         drvc = fixme_di->priv;
271         devices = NULL;
272         serial_flush(serial);
273
274         /*
275          * There's no way to get an ID from the multimeter. It just sends data
276          * periodically, so the best we can do is check if the packets match
277          * the expected format.
278          */
279
280         /* Let's get a bit of data and see if we can find a packet. */
281         len = sizeof(buf);
282
283         /* Request a packet if the DMM requires this. */
284         if (dmm->packet_request) {
285                 if ((ret = dmm->packet_request(serial)) < 0) {
286                         sr_err("Failed to request packet: %d.", ret);
287                         return FALSE;
288                 }
289         }
290
291         ret = serial_stream_detect(serial, buf, &len, dmm->packet_size,
292                                    dmm->packet_valid, 1000,
293                                    dmm->baudrate);
294         if (ret != SR_OK)
295                 goto scan_cleanup;
296
297         /*
298          * If we dropped more than two packets worth of data, something is
299          * wrong. We shouldn't quit however, since the dropped bytes might be
300          * just zeroes at the beginning of the stream. Those can occur as a
301          * combination of the nonstandard cable that ships with this device and
302          * the serial port or USB to serial adapter.
303          */
304         dropped = len - dmm->packet_size;
305         if (dropped > 2 * dmm->packet_size)
306                 sr_warn("Had to drop too much data.");
307
308         sr_info("Found device on port %s.", conn);
309
310         if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, dmm->vendor,
311                                     dmm->device, "")))
312                 goto scan_cleanup;
313
314         if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
315                 sr_err("Device context malloc failed.");
316                 goto scan_cleanup;
317         }
318
319         devc->serial = serial;
320
321         sdi->priv = devc;
322         sdi->driver = fixme_di;
323         if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
324                 goto scan_cleanup;
325         sdi->probes = g_slist_append(sdi->probes, probe);
326         drvc->instances = g_slist_append(drvc->instances, sdi);
327         devices = g_slist_append(devices, sdi);
328
329 scan_cleanup:
330         serial_close(serial);
331
332         return devices;
333 }
334
335 static GSList *hw_scan(GSList *options)
336 {
337         struct sr_hwopt *opt;
338         GSList *l, *devices;
339         const char *conn, *serialcomm;
340         int dmm_idx;
341
342         conn = serialcomm = NULL;
343         for (l = options; l; l = l->next) {
344                 opt = l->data;
345                 switch (opt->hwopt) {
346                 case SR_HWOPT_CONN:
347                         conn = opt->value;
348                         break;
349                 case SR_HWOPT_SERIALCOMM:
350                         serialcomm = opt->value;
351                         break;
352                 }
353         }
354         if (!conn)
355                 return NULL;
356
357         if (!strcmp(fixme_di->name, "digitek-dt4000zc"))
358                 dmm_idx = 0;
359         if (!strcmp(fixme_di->name, "tekpower-tp4000zc"))
360                 dmm_idx = 1;
361         if (!strcmp(fixme_di->name, "metex-me31"))
362                 dmm_idx = 2;
363         if (!strcmp(fixme_di->name, "peaktech-3410"))
364                 dmm_idx = 3;
365         if (!strcmp(fixme_di->name, "mastech-mas345"))
366                 dmm_idx = 4;
367         if (!strcmp(fixme_di->name, "va-va18b"))
368                 dmm_idx = 5;
369         if (!strcmp(fixme_di->name, "metex-m3640d"))
370                 dmm_idx = 6;
371         if (!strcmp(fixme_di->name, "peaktech-4370"))
372                 dmm_idx = 7;
373         if (!strcmp(fixme_di->name, "pce-pce-dm32"))
374                 dmm_idx = 8;
375         if (!strcmp(fixme_di->name, "radioshack-22-168"))
376                 dmm_idx = 9;
377         if (!strcmp(fixme_di->name, "radioshack-22-812"))
378                 dmm_idx = 10;
379
380         if (serialcomm) {
381                 /* Use the provided comm specs. */
382                 devices = scan(conn, serialcomm, &dmms[dmm_idx]);
383         } else {
384                 /* Try the default. */
385                 devices = scan(conn, dmms[dmm_idx].conn, &dmms[dmm_idx]);
386         }
387
388         return devices;
389 }
390
391 static GSList *hw_dev_list(void)
392 {
393         struct drv_context *drvc;
394
395         drvc = fixme_di->priv;
396
397         return drvc->instances;
398 }
399
400 static int hw_dev_open(struct sr_dev_inst *sdi)
401 {
402         struct dev_context *devc;
403
404         if (!(devc = sdi->priv)) {
405                 sr_err("sdi->priv was NULL.");
406                 return SR_ERR_BUG;
407         }
408
409         if (serial_open(devc->serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
410                 return SR_ERR;
411
412         sdi->status = SR_ST_ACTIVE;
413
414         return SR_OK;
415 }
416
417 static int hw_dev_close(struct sr_dev_inst *sdi)
418 {
419         struct dev_context *devc;
420
421         if (!(devc = sdi->priv)) {
422                 sr_err("sdi->priv was NULL.");
423                 return SR_ERR_BUG;
424         }
425
426         if (devc->serial && devc->serial->fd != -1) {
427                 serial_close(devc->serial);
428                 sdi->status = SR_ST_INACTIVE;
429         }
430
431         return SR_OK;
432 }
433
434 static int hw_cleanup(void)
435 {
436         clear_instances();
437
438         return SR_OK;
439 }
440
441 static int hw_info_get(int info_id, const void **data,
442                        const struct sr_dev_inst *sdi)
443 {
444         (void)sdi;
445
446         switch (info_id) {
447         case SR_DI_HWOPTS:
448                 *data = hwopts;
449                 break;
450         case SR_DI_HWCAPS:
451                 *data = hwcaps;
452                 break;
453         case SR_DI_NUM_PROBES:
454                 *data = GINT_TO_POINTER(1);
455                 break;
456         case SR_DI_PROBE_NAMES:
457                 *data = probe_names;
458                 break;
459         default:
460                 return SR_ERR_ARG;
461         }
462
463         return SR_OK;
464 }
465
466 static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
467                              const void *value)
468 {
469         struct dev_context *devc;
470
471         if (sdi->status != SR_ST_ACTIVE)
472                 return SR_ERR;
473
474         if (!(devc = sdi->priv)) {
475                 sr_err("sdi->priv was NULL.");
476                 return SR_ERR_BUG;
477         }
478
479         switch (hwcap) {
480         case SR_HWCAP_LIMIT_SAMPLES:
481                 devc->limit_samples = *(const uint64_t *)value;
482                 sr_dbg("Setting sample limit to %" PRIu64 ".",
483                        devc->limit_samples);
484                 break;
485         default:
486                 sr_err("Unknown capability: %d.", hwcap);
487                 return SR_ERR;
488                 break;
489         }
490
491         return SR_OK;
492 }
493
494 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
495                                     void *cb_data)
496 {
497         struct sr_datafeed_packet packet;
498         struct sr_datafeed_header header;
499         struct sr_datafeed_meta_analog meta;
500         struct dev_context *devc;
501         int (*receive_data)(int, int, void *) = NULL;
502
503         if (!(devc = sdi->priv)) {
504                 sr_err("sdi->priv was NULL.");
505                 return SR_ERR_BUG;
506         }
507
508         sr_dbg("Starting acquisition.");
509
510         devc->cb_data = cb_data;
511
512         /*
513          * Reset the number of samples to take. If we've already collected our
514          * quota, but we start a new session, and don't reset this, we'll just
515          * quit without acquiring any new samples.
516          */
517         devc->num_samples = 0;
518
519         /* Send header packet to the session bus. */
520         sr_dbg("Sending SR_DF_HEADER.");
521         packet.type = SR_DF_HEADER;
522         packet.payload = (uint8_t *)&header;
523         header.feed_version = 1;
524         gettimeofday(&header.starttime, NULL);
525         sr_session_send(devc->cb_data, &packet);
526
527         /* Send metadata about the SR_DF_ANALOG packets to come. */
528         sr_dbg("Sending SR_DF_META_ANALOG.");
529         packet.type = SR_DF_META_ANALOG;
530         packet.payload = &meta;
531         meta.num_probes = 1;
532         sr_session_send(devc->cb_data, &packet);
533
534         if (!strcmp(fixme_di->name, "digitek-dt4000zc"))
535                 receive_data = digitek_dt4000zc_receive_data;
536         if (!strcmp(fixme_di->name, "tekpower-tp4000zc"))
537                 receive_data = tekpower_tp4000zc_receive_data;
538         if (!strcmp(fixme_di->name, "metex-me31"))
539                 receive_data = metex_me31_receive_data;
540         if (!strcmp(fixme_di->name, "peaktech-3410"))
541                 receive_data = peaktech_3410_receive_data;
542         if (!strcmp(fixme_di->name, "mastech-mas345"))
543                 receive_data = mastech_mas345_receive_data;
544         if (!strcmp(fixme_di->name, "va-va18b"))
545                 receive_data = va_va18b_receive_data;
546         if (!strcmp(fixme_di->name, "metex-m3640d"))
547                 receive_data = metex_m3640d_receive_data;
548         if (!strcmp(fixme_di->name, "peaktech-4370"))
549                 receive_data = peaktech_4370_receive_data;
550         if (!strcmp(fixme_di->name, "pce-pce-dm32"))
551                 receive_data = pce_pce_dm32_receive_data;
552         if (!strcmp(fixme_di->name, "radioshack-22-168"))
553                 receive_data = radioshack_22_168_receive_data;
554         if (!strcmp(fixme_di->name, "radioshack-22-812"))
555                 receive_data = radioshack_22_812_receive_data;
556
557         /* Poll every 50ms, or whenever some data comes in. */
558         sr_source_add(devc->serial->fd, G_IO_IN, 50,
559                       receive_data, (void *)sdi);
560
561         return SR_OK;
562 }
563
564 static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
565 {
566         struct sr_datafeed_packet packet;
567         struct dev_context *devc;
568
569         if (sdi->status != SR_ST_ACTIVE)
570                 return SR_ERR;
571
572         if (!(devc = sdi->priv)) {
573                 sr_err("sdi->priv was NULL.");
574                 return SR_ERR_BUG;
575         }
576
577         sr_dbg("Stopping acquisition.");
578
579         sr_source_remove(devc->serial->fd);
580         hw_dev_close((struct sr_dev_inst *)sdi);
581
582         /* Send end packet to the session bus. */
583         sr_dbg("Sending SR_DF_END.");
584         packet.type = SR_DF_END;
585         sr_session_send(cb_data, &packet);
586
587         return SR_OK;
588 }
589
590 SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info = {
591         .name = "digitek-dt4000zc",
592         .longname = "Digitek DT4000ZC",
593         .api_version = 1,
594         .init = hw_init_digitek_dt4000zc,
595         .cleanup = hw_cleanup,
596         .scan = hw_scan,
597         .dev_list = hw_dev_list,
598         .dev_clear = clear_instances,
599         .dev_open = hw_dev_open,
600         .dev_close = hw_dev_close,
601         .info_get = hw_info_get,
602         .dev_config_set = hw_dev_config_set,
603         .dev_acquisition_start = hw_dev_acquisition_start,
604         .dev_acquisition_stop = hw_dev_acquisition_stop,
605         .priv = NULL,
606 };
607
608 SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info = {
609         .name = "tekpower-tp4000zc",
610         .longname = "TekPower TP4000ZC",
611         .api_version = 1,
612         .init = hw_init_tekpower_tp4000zc,
613         .cleanup = hw_cleanup,
614         .scan = hw_scan,
615         .dev_list = hw_dev_list,
616         .dev_clear = clear_instances,
617         .dev_open = hw_dev_open,
618         .dev_close = hw_dev_close,
619         .info_get = hw_info_get,
620         .dev_config_set = hw_dev_config_set,
621         .dev_acquisition_start = hw_dev_acquisition_start,
622         .dev_acquisition_stop = hw_dev_acquisition_stop,
623         .priv = NULL,
624 };
625
626 SR_PRIV struct sr_dev_driver metex_me31_driver_info = {
627         .name = "metex-me31",
628         .longname = "Metex ME-31",
629         .api_version = 1,
630         .init = hw_init_metex_me31,
631         .cleanup = hw_cleanup,
632         .scan = hw_scan,
633         .dev_list = hw_dev_list,
634         .dev_clear = clear_instances,
635         .dev_open = hw_dev_open,
636         .dev_close = hw_dev_close,
637         .info_get = hw_info_get,
638         .dev_config_set = hw_dev_config_set,
639         .dev_acquisition_start = hw_dev_acquisition_start,
640         .dev_acquisition_stop = hw_dev_acquisition_stop,
641         .priv = NULL,
642 };
643
644 SR_PRIV struct sr_dev_driver peaktech_3410_driver_info = {
645         .name = "peaktech-3410",
646         .longname = "PeakTech 3410",
647         .api_version = 1,
648         .init = hw_init_peaktech_3410,
649         .cleanup = hw_cleanup,
650         .scan = hw_scan,
651         .dev_list = hw_dev_list,
652         .dev_clear = clear_instances,
653         .dev_open = hw_dev_open,
654         .dev_close = hw_dev_close,
655         .info_get = hw_info_get,
656         .dev_config_set = hw_dev_config_set,
657         .dev_acquisition_start = hw_dev_acquisition_start,
658         .dev_acquisition_stop = hw_dev_acquisition_stop,
659         .priv = NULL,
660 };
661
662 SR_PRIV struct sr_dev_driver mastech_mas345_driver_info = {
663         .name = "mastech-mas345",
664         .longname = "MASTECH MAS345",
665         .api_version = 1,
666         .init = hw_init_mastech_mas345,
667         .cleanup = hw_cleanup,
668         .scan = hw_scan,
669         .dev_list = hw_dev_list,
670         .dev_clear = clear_instances,
671         .dev_open = hw_dev_open,
672         .dev_close = hw_dev_close,
673         .info_get = hw_info_get,
674         .dev_config_set = hw_dev_config_set,
675         .dev_acquisition_start = hw_dev_acquisition_start,
676         .dev_acquisition_stop = hw_dev_acquisition_stop,
677         .priv = NULL,
678 };
679
680 SR_PRIV struct sr_dev_driver va_va18b_driver_info = {
681         .name = "va-va18b",
682         .longname = "V&A VA18B",
683         .api_version = 1,
684         .init = hw_init_va_va18b,
685         .cleanup = hw_cleanup,
686         .scan = hw_scan,
687         .dev_list = hw_dev_list,
688         .dev_clear = clear_instances,
689         .dev_open = hw_dev_open,
690         .dev_close = hw_dev_close,
691         .info_get = hw_info_get,
692         .dev_config_set = hw_dev_config_set,
693         .dev_acquisition_start = hw_dev_acquisition_start,
694         .dev_acquisition_stop = hw_dev_acquisition_stop,
695         .priv = NULL,
696 };
697
698 SR_PRIV struct sr_dev_driver metex_m3640d_driver_info = {
699         .name = "metex-m3640d",
700         .longname = "Metex M-3640D",
701         .api_version = 1,
702         .init = hw_init_metex_m3640d,
703         .cleanup = hw_cleanup,
704         .scan = hw_scan,
705         .dev_list = hw_dev_list,
706         .dev_clear = clear_instances,
707         .dev_open = hw_dev_open,
708         .dev_close = hw_dev_close,
709         .info_get = hw_info_get,
710         .dev_config_set = hw_dev_config_set,
711         .dev_acquisition_start = hw_dev_acquisition_start,
712         .dev_acquisition_stop = hw_dev_acquisition_stop,
713         .priv = NULL,
714 };
715
716 SR_PRIV struct sr_dev_driver peaktech_4370_driver_info = {
717         .name = "peaktech-4370",
718         .longname = "PeakTech 4370",
719         .api_version = 1,
720         .init = hw_init_peaktech_4370,
721         .cleanup = hw_cleanup,
722         .scan = hw_scan,
723         .dev_list = hw_dev_list,
724         .dev_clear = clear_instances,
725         .dev_open = hw_dev_open,
726         .dev_close = hw_dev_close,
727         .info_get = hw_info_get,
728         .dev_config_set = hw_dev_config_set,
729         .dev_acquisition_start = hw_dev_acquisition_start,
730         .dev_acquisition_stop = hw_dev_acquisition_stop,
731         .priv = NULL,
732 };
733
734 SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info = {
735         .name = "pce-pce-dm32",
736         .longname = "PCE PCE-DM32",
737         .api_version = 1,
738         .init = hw_init_pce_pce_dm32,
739         .cleanup = hw_cleanup,
740         .scan = hw_scan,
741         .dev_list = hw_dev_list,
742         .dev_clear = clear_instances,
743         .dev_open = hw_dev_open,
744         .dev_close = hw_dev_close,
745         .info_get = hw_info_get,
746         .dev_config_set = hw_dev_config_set,
747         .dev_acquisition_start = hw_dev_acquisition_start,
748         .dev_acquisition_stop = hw_dev_acquisition_stop,
749         .priv = NULL,
750 };
751
752 SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info = {
753         .name = "radioshack-22-168",
754         .longname = "RadioShack 22-168",
755         .api_version = 1,
756         .init = hw_init_radioshack_22_168,
757         .cleanup = hw_cleanup,
758         .scan = hw_scan,
759         .dev_list = hw_dev_list,
760         .dev_clear = clear_instances,
761         .dev_open = hw_dev_open,
762         .dev_close = hw_dev_close,
763         .info_get = hw_info_get,
764         .dev_config_set = hw_dev_config_set,
765         .dev_acquisition_start = hw_dev_acquisition_start,
766         .dev_acquisition_stop = hw_dev_acquisition_stop,
767         .priv = NULL,
768 };
769
770 SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info = {
771         .name = "radioshack-22-812",
772         .longname = "RadioShack 22-812",
773         .api_version = 1,
774         .init = hw_init_radioshack_22_812,
775         .cleanup = hw_cleanup,
776         .scan = hw_scan,
777         .dev_list = hw_dev_list,
778         .dev_clear = clear_instances,
779         .dev_open = hw_dev_open,
780         .dev_close = hw_dev_close,
781         .info_get = hw_info_get,
782         .dev_config_set = hw_dev_config_set,
783         .dev_acquisition_start = hw_dev_acquisition_start,
784         .dev_acquisition_stop = hw_dev_acquisition_stop,
785         .priv = NULL,
786 };