]>
Commit | Line | Data |
---|---|---|
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 <sys/types.h> | |
23 | #include <sys/stat.h> | |
24 | #include <fcntl.h> | |
25 | #include <string.h> | |
26 | #include <errno.h> | |
27 | #include <glib.h> | |
28 | #include "libsigrok.h" | |
29 | #include "libsigrok-internal.h" | |
30 | #include "protocol.h" | |
31 | ||
32 | static const int32_t hwopts[] = { | |
33 | SR_CONF_CONN, | |
34 | SR_CONF_SERIALCOMM, | |
35 | }; | |
36 | ||
37 | static const int32_t hwcaps[] = { | |
38 | SR_CONF_MULTIMETER, | |
39 | SR_CONF_LIMIT_SAMPLES, | |
40 | SR_CONF_LIMIT_MSEC, | |
41 | SR_CONF_CONTINUOUS, | |
42 | }; | |
43 | ||
44 | SR_PRIV struct sr_dev_driver digitek_dt4000zc_driver_info; | |
45 | SR_PRIV struct sr_dev_driver tekpower_tp4000zc_driver_info; | |
46 | SR_PRIV struct sr_dev_driver metex_me31_driver_info; | |
47 | SR_PRIV struct sr_dev_driver peaktech_3410_driver_info; | |
48 | SR_PRIV struct sr_dev_driver mastech_mas345_driver_info; | |
49 | SR_PRIV struct sr_dev_driver va_va18b_driver_info; | |
50 | SR_PRIV struct sr_dev_driver metex_m3640d_driver_info; | |
51 | SR_PRIV struct sr_dev_driver metex_m4650cr_driver_info; | |
52 | SR_PRIV struct sr_dev_driver peaktech_4370_driver_info; | |
53 | SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info; | |
54 | SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info; | |
55 | SR_PRIV struct sr_dev_driver radioshack_22_805_driver_info; | |
56 | SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info; | |
57 | SR_PRIV struct sr_dev_driver tecpel_dmm_8061_ser_driver_info; | |
58 | SR_PRIV struct sr_dev_driver voltcraft_m3650d_driver_info; | |
59 | SR_PRIV struct sr_dev_driver voltcraft_m4650cr_driver_info; | |
60 | SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info; | |
61 | SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info; | |
62 | SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info; | |
63 | SR_PRIV struct sr_dev_driver uni_t_ut60a_ser_driver_info; | |
64 | SR_PRIV struct sr_dev_driver uni_t_ut60e_ser_driver_info; | |
65 | SR_PRIV struct sr_dev_driver uni_t_ut61d_ser_driver_info; | |
66 | SR_PRIV struct sr_dev_driver uni_t_ut61e_ser_driver_info; | |
67 | SR_PRIV struct sr_dev_driver iso_tech_idm103n_driver_info; | |
68 | ||
69 | SR_PRIV struct dmm_info dmms[] = { | |
70 | { | |
71 | "Digitek", "DT4000ZC", "2400/8n1/dtr=1", 2400, | |
72 | FS9721_PACKET_SIZE, NULL, | |
73 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
74 | sr_fs9721_10_temp_c, | |
75 | &digitek_dt4000zc_driver_info, receive_data_DIGITEK_DT4000ZC, | |
76 | }, | |
77 | { | |
78 | "TekPower", "TP4000ZC", "2400/8n1/dtr=1", 2400, | |
79 | FS9721_PACKET_SIZE, NULL, | |
80 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
81 | sr_fs9721_10_temp_c, | |
82 | &tekpower_tp4000zc_driver_info, receive_data_TEKPOWER_TP4000ZC, | |
83 | }, | |
84 | { | |
85 | "Metex", "ME-31", "600/7n2/rts=0/dtr=1", 600, | |
86 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
87 | sr_metex14_packet_valid, sr_metex14_parse, | |
88 | NULL, | |
89 | &metex_me31_driver_info, receive_data_METEX_ME31, | |
90 | }, | |
91 | { | |
92 | "Peaktech", "3410", "600/7n2/rts=0/dtr=1", 600, | |
93 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
94 | sr_metex14_packet_valid, sr_metex14_parse, | |
95 | NULL, | |
96 | &peaktech_3410_driver_info, receive_data_PEAKTECH_3410, | |
97 | }, | |
98 | { | |
99 | "MASTECH", "MAS345", "600/7n2/rts=0/dtr=1", 600, | |
100 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
101 | sr_metex14_packet_valid, sr_metex14_parse, | |
102 | NULL, | |
103 | &mastech_mas345_driver_info, receive_data_MASTECH_MAS345, | |
104 | }, | |
105 | { | |
106 | "V&A", "VA18B", "2400/8n1", 2400, | |
107 | FS9721_PACKET_SIZE, NULL, | |
108 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
109 | sr_fs9721_01_temp_c, | |
110 | &va_va18b_driver_info, receive_data_VA_VA18B, | |
111 | }, | |
112 | { | |
113 | "Metex", "M-3640D", "1200/7n2/rts=0/dtr=1", 1200, | |
114 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
115 | sr_metex14_packet_valid, sr_metex14_parse, | |
116 | NULL, | |
117 | &metex_m3640d_driver_info, receive_data_METEX_M3640D, | |
118 | }, | |
119 | { | |
120 | "Metex", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, | |
121 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
122 | sr_metex14_packet_valid, sr_metex14_parse, | |
123 | NULL, | |
124 | &metex_m4650cr_driver_info, receive_data_METEX_M4650CR, | |
125 | }, | |
126 | { | |
127 | "PeakTech", "4370", "1200/7n2/rts=0/dtr=1", 1200, | |
128 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
129 | sr_metex14_packet_valid, sr_metex14_parse, | |
130 | NULL, | |
131 | &peaktech_4370_driver_info, receive_data_PEAKTECH_4370, | |
132 | }, | |
133 | { | |
134 | "PCE", "PCE-DM32", "2400/8n1", 2400, | |
135 | FS9721_PACKET_SIZE, NULL, | |
136 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
137 | sr_fs9721_01_10_temp_f_c, | |
138 | &pce_pce_dm32_driver_info, receive_data_PCE_PCE_DM32, | |
139 | }, | |
140 | { | |
141 | "RadioShack", "22-168", "1200/7n2/rts=0/dtr=1", 1200, | |
142 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
143 | sr_metex14_packet_valid, sr_metex14_parse, | |
144 | NULL, | |
145 | &radioshack_22_168_driver_info, receive_data_RADIOSHACK_22_168, | |
146 | }, | |
147 | { | |
148 | "RadioShack", "22-805", "600/7n2/rts=0/dtr=1", 600, | |
149 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
150 | sr_metex14_packet_valid, sr_metex14_parse, | |
151 | NULL, | |
152 | &radioshack_22_805_driver_info, receive_data_RADIOSHACK_22_805, | |
153 | }, | |
154 | { | |
155 | "RadioShack", "22-812", "4800/8n1/rts=0/dtr=1", 4800, | |
156 | RS9LCD_PACKET_SIZE, NULL, | |
157 | sr_rs9lcd_packet_valid, sr_rs9lcd_parse, | |
158 | NULL, | |
159 | &radioshack_22_812_driver_info, receive_data_RADIOSHACK_22_812, | |
160 | }, | |
161 | { | |
162 | "Tecpel", "DMM-8061 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
163 | 2400, FS9721_PACKET_SIZE, NULL, | |
164 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
165 | sr_fs9721_00_temp_c, | |
166 | &tecpel_dmm_8061_ser_driver_info, | |
167 | receive_data_TECPEL_DMM_8061_SER, | |
168 | }, | |
169 | { | |
170 | "Voltcraft", "M-3650D", "1200/7n2/rts=0/dtr=1", 1200, | |
171 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
172 | sr_metex14_packet_valid, sr_metex14_parse, | |
173 | NULL, | |
174 | &voltcraft_m3650d_driver_info, receive_data_VOLTCRAFT_M3650D, | |
175 | }, | |
176 | { | |
177 | "Voltcraft", "M-4650CR", "1200/7n2/rts=0/dtr=1", 1200, | |
178 | METEX14_PACKET_SIZE, sr_metex14_packet_request, | |
179 | sr_metex14_packet_valid, sr_metex14_parse, | |
180 | NULL, | |
181 | &voltcraft_m4650cr_driver_info, receive_data_VOLTCRAFT_M4650CR, | |
182 | }, | |
183 | { | |
184 | "Voltcraft", "VC-820 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
185 | 2400, FS9721_PACKET_SIZE, NULL, | |
186 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
187 | NULL, | |
188 | &voltcraft_vc820_ser_driver_info, | |
189 | receive_data_VOLTCRAFT_VC820_SER, | |
190 | }, | |
191 | { | |
192 | /* | |
193 | * Note: The VC830 doesn't set the 'volt' and 'diode' bits of | |
194 | * the FS9922 protocol. Instead, it only sets the user-defined | |
195 | * bit "z1" to indicate "diode mode" and "voltage". | |
196 | */ | |
197 | "Voltcraft", "VC-830 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
198 | 2400, FS9922_PACKET_SIZE, NULL, | |
199 | sr_fs9922_packet_valid, sr_fs9922_parse, | |
200 | &sr_fs9922_z1_diode, | |
201 | &voltcraft_vc830_ser_driver_info, | |
202 | receive_data_VOLTCRAFT_VC830_SER, | |
203 | }, | |
204 | { | |
205 | "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
206 | 2400, FS9721_PACKET_SIZE, NULL, | |
207 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
208 | sr_fs9721_00_temp_c, | |
209 | &voltcraft_vc840_ser_driver_info, | |
210 | receive_data_VOLTCRAFT_VC840_SER, | |
211 | }, | |
212 | { | |
213 | "UNI-T", "UT60A (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
214 | 2400, FS9721_PACKET_SIZE, NULL, | |
215 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
216 | NULL, | |
217 | &uni_t_ut60a_ser_driver_info, | |
218 | receive_data_UNI_T_UT60A_SER, | |
219 | }, | |
220 | { | |
221 | "UNI-T", "UT60E (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
222 | 2400, FS9721_PACKET_SIZE, NULL, | |
223 | sr_fs9721_packet_valid, sr_fs9721_parse, | |
224 | sr_fs9721_00_temp_c, | |
225 | &uni_t_ut60e_ser_driver_info, | |
226 | receive_data_UNI_T_UT60E_SER, | |
227 | }, | |
228 | { | |
229 | "UNI-T", "UT61D (UT-D02 cable)", "2400/8n1/rts=0/dtr=1", | |
230 | 2400, FS9922_PACKET_SIZE, NULL, | |
231 | sr_fs9922_packet_valid, sr_fs9922_parse, NULL, | |
232 | &uni_t_ut61d_ser_driver_info, receive_data_UNI_T_UT61D_SER, | |
233 | }, | |
234 | { | |
235 | /* Note: ES51922 baudrate is actually 19230! */ | |
236 | "UNI-T", "UT61E (UT-D02 cable)", "19200/7o1/rts=0/dtr=1", | |
237 | 19200, ES51922_PACKET_SIZE, NULL, | |
238 | sr_es51922_packet_valid, sr_es51922_parse, NULL, | |
239 | &uni_t_ut61e_ser_driver_info, receive_data_UNI_T_UT61E_SER, | |
240 | }, | |
241 | { | |
242 | "ISO-TECH", "IDM103N", "2400/7o1/rts=0/dtr=1", | |
243 | 2400, ES519XX_11B_PACKET_SIZE, NULL, | |
244 | sr_es519xx_2400_11b_packet_valid, sr_es519xx_2400_11b_parse, NULL, | |
245 | &iso_tech_idm103n_driver_info, receive_data_ISO_TECH_IDM103N, | |
246 | }, | |
247 | }; | |
248 | ||
249 | static int dev_clear(int dmm) | |
250 | { | |
251 | return std_dev_clear(dmms[dmm].di, NULL); | |
252 | } | |
253 | ||
254 | static int init(struct sr_context *sr_ctx, int dmm) | |
255 | { | |
256 | sr_dbg("Selected '%s' subdriver.", dmms[dmm].di->name); | |
257 | ||
258 | return std_init(sr_ctx, dmms[dmm].di, LOG_PREFIX); | |
259 | } | |
260 | ||
261 | static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm) | |
262 | { | |
263 | struct sr_dev_inst *sdi; | |
264 | struct drv_context *drvc; | |
265 | struct dev_context *devc; | |
266 | struct sr_probe *probe; | |
267 | struct sr_serial_dev_inst *serial; | |
268 | GSList *devices; | |
269 | int dropped, ret; | |
270 | size_t len; | |
271 | uint8_t buf[128]; | |
272 | ||
273 | if (!(serial = sr_serial_dev_inst_new(conn, serialcomm))) | |
274 | return NULL; | |
275 | ||
276 | if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK) | |
277 | return NULL; | |
278 | ||
279 | sr_info("Probing serial port %s.", conn); | |
280 | ||
281 | drvc = dmms[dmm].di->priv; | |
282 | devices = NULL; | |
283 | serial_flush(serial); | |
284 | ||
285 | /* Request a packet if the DMM requires this. */ | |
286 | if (dmms[dmm].packet_request) { | |
287 | if ((ret = dmms[dmm].packet_request(serial)) < 0) { | |
288 | sr_err("Failed to request packet: %d.", ret); | |
289 | return FALSE; | |
290 | } | |
291 | } | |
292 | ||
293 | /* | |
294 | * There's no way to get an ID from the multimeter. It just sends data | |
295 | * periodically (or upon request), so the best we can do is check if | |
296 | * the packets match the expected format. | |
297 | */ | |
298 | ||
299 | /* Let's get a bit of data and see if we can find a packet. */ | |
300 | len = sizeof(buf); | |
301 | ret = serial_stream_detect(serial, buf, &len, dmms[dmm].packet_size, | |
302 | dmms[dmm].packet_valid, 1000, | |
303 | dmms[dmm].baudrate); | |
304 | if (ret != SR_OK) | |
305 | goto scan_cleanup; | |
306 | ||
307 | /* | |
308 | * If we dropped more than two packets worth of data, something is | |
309 | * wrong. We shouldn't quit however, since the dropped bytes might be | |
310 | * just zeroes at the beginning of the stream. Those can occur as a | |
311 | * combination of the nonstandard cable that ships with some devices | |
312 | * and the serial port or USB to serial adapter. | |
313 | */ | |
314 | dropped = len - dmms[dmm].packet_size; | |
315 | if (dropped > 2 * dmms[dmm].packet_size) | |
316 | sr_warn("Had to drop too much data."); | |
317 | ||
318 | sr_info("Found device on port %s.", conn); | |
319 | ||
320 | if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, dmms[dmm].vendor, | |
321 | dmms[dmm].device, ""))) | |
322 | goto scan_cleanup; | |
323 | ||
324 | if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) { | |
325 | sr_err("Device context malloc failed."); | |
326 | goto scan_cleanup; | |
327 | } | |
328 | ||
329 | sdi->inst_type = SR_INST_SERIAL; | |
330 | sdi->conn = serial; | |
331 | ||
332 | sdi->priv = devc; | |
333 | sdi->driver = dmms[dmm].di; | |
334 | if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1"))) | |
335 | goto scan_cleanup; | |
336 | sdi->probes = g_slist_append(sdi->probes, probe); | |
337 | drvc->instances = g_slist_append(drvc->instances, sdi); | |
338 | devices = g_slist_append(devices, sdi); | |
339 | ||
340 | scan_cleanup: | |
341 | serial_close(serial); | |
342 | ||
343 | return devices; | |
344 | } | |
345 | ||
346 | static GSList *scan(GSList *options, int dmm) | |
347 | { | |
348 | struct sr_config *src; | |
349 | GSList *l, *devices; | |
350 | const char *conn, *serialcomm; | |
351 | ||
352 | conn = serialcomm = NULL; | |
353 | for (l = options; l; l = l->next) { | |
354 | src = l->data; | |
355 | switch (src->key) { | |
356 | case SR_CONF_CONN: | |
357 | conn = g_variant_get_string(src->data, NULL); | |
358 | break; | |
359 | case SR_CONF_SERIALCOMM: | |
360 | serialcomm = g_variant_get_string(src->data, NULL); | |
361 | break; | |
362 | } | |
363 | } | |
364 | if (!conn) | |
365 | return NULL; | |
366 | ||
367 | if (serialcomm) { | |
368 | /* Use the provided comm specs. */ | |
369 | devices = sdmm_scan(conn, serialcomm, dmm); | |
370 | } else { | |
371 | /* Try the default. */ | |
372 | devices = sdmm_scan(conn, dmms[dmm].conn, dmm); | |
373 | } | |
374 | ||
375 | return devices; | |
376 | } | |
377 | ||
378 | static GSList *dev_list(int dmm) | |
379 | { | |
380 | return ((struct drv_context *)(dmms[dmm].di->priv))->instances; | |
381 | } | |
382 | ||
383 | static int dev_open(struct sr_dev_inst *sdi) | |
384 | { | |
385 | struct sr_serial_dev_inst *serial; | |
386 | ||
387 | serial = sdi->conn; | |
388 | if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK) | |
389 | return SR_ERR; | |
390 | ||
391 | sdi->status = SR_ST_ACTIVE; | |
392 | ||
393 | return SR_OK; | |
394 | } | |
395 | ||
396 | static int cleanup(int dmm) | |
397 | { | |
398 | return dev_clear(dmm); | |
399 | } | |
400 | ||
401 | static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, | |
402 | const struct sr_probe_group *probe_group) | |
403 | { | |
404 | struct dev_context *devc; | |
405 | ||
406 | (void)probe_group; | |
407 | ||
408 | if (sdi->status != SR_ST_ACTIVE) | |
409 | return SR_ERR_DEV_CLOSED; | |
410 | ||
411 | if (!(devc = sdi->priv)) { | |
412 | sr_err("sdi->priv was NULL."); | |
413 | return SR_ERR_BUG; | |
414 | } | |
415 | ||
416 | switch (id) { | |
417 | case SR_CONF_LIMIT_SAMPLES: | |
418 | devc->limit_samples = g_variant_get_uint64(data); | |
419 | sr_dbg("Setting sample limit to %" PRIu64 ".", | |
420 | devc->limit_samples); | |
421 | break; | |
422 | case SR_CONF_LIMIT_MSEC: | |
423 | devc->limit_msec = g_variant_get_uint64(data); | |
424 | sr_dbg("Setting time limit to %" PRIu64 "ms.", | |
425 | devc->limit_msec); | |
426 | break; | |
427 | default: | |
428 | return SR_ERR_NA; | |
429 | } | |
430 | ||
431 | return SR_OK; | |
432 | } | |
433 | ||
434 | static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, | |
435 | const struct sr_probe_group *probe_group) | |
436 | { | |
437 | (void)sdi; | |
438 | (void)probe_group; | |
439 | ||
440 | switch (key) { | |
441 | case SR_CONF_SCAN_OPTIONS: | |
442 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, | |
443 | hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t)); | |
444 | break; | |
445 | case SR_CONF_DEVICE_OPTIONS: | |
446 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, | |
447 | hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t)); | |
448 | break; | |
449 | default: | |
450 | return SR_ERR_NA; | |
451 | } | |
452 | ||
453 | return SR_OK; | |
454 | } | |
455 | ||
456 | static int dev_acquisition_start(const struct sr_dev_inst *sdi, | |
457 | void *cb_data, int dmm) | |
458 | { | |
459 | struct dev_context *devc; | |
460 | struct sr_serial_dev_inst *serial; | |
461 | ||
462 | if (sdi->status != SR_ST_ACTIVE) | |
463 | return SR_ERR_DEV_CLOSED; | |
464 | ||
465 | if (!(devc = sdi->priv)) { | |
466 | sr_err("sdi->priv was NULL."); | |
467 | return SR_ERR_BUG; | |
468 | } | |
469 | ||
470 | devc->cb_data = cb_data; | |
471 | ||
472 | /* | |
473 | * Reset the number of samples to take. If we've already collected our | |
474 | * quota, but we start a new session, and don't reset this, we'll just | |
475 | * quit without acquiring any new samples. | |
476 | */ | |
477 | devc->num_samples = 0; | |
478 | devc->starttime = g_get_monotonic_time(); | |
479 | ||
480 | /* Send header packet to the session bus. */ | |
481 | std_session_send_df_header(cb_data, LOG_PREFIX); | |
482 | ||
483 | /* Poll every 50ms, or whenever some data comes in. */ | |
484 | serial = sdi->conn; | |
485 | serial_source_add(serial, G_IO_IN, 50, | |
486 | dmms[dmm].receive_data, (void *)sdi); | |
487 | ||
488 | return SR_OK; | |
489 | } | |
490 | ||
491 | static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) | |
492 | { | |
493 | return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close, | |
494 | sdi->conn, LOG_PREFIX); | |
495 | } | |
496 | ||
497 | /* Driver-specific API function wrappers */ | |
498 | #define HW_INIT(X) \ | |
499 | static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); } | |
500 | #define HW_CLEANUP(X) \ | |
501 | static int cleanup_##X(void) { return cleanup(X); } | |
502 | #define HW_SCAN(X) \ | |
503 | static GSList *scan_##X(GSList *options) { return scan(options, X); } | |
504 | #define HW_DEV_LIST(X) \ | |
505 | static GSList *dev_list_##X(void) { return dev_list(X); } | |
506 | #define HW_DEV_CLEAR(X) \ | |
507 | static int dev_clear_##X(void) { return dev_clear(X); } | |
508 | #define HW_DEV_ACQUISITION_START(X) \ | |
509 | static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ | |
510 | void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } | |
511 | ||
512 | /* Driver structs and API function wrappers */ | |
513 | #define DRV(ID, ID_UPPER, NAME, LONGNAME) \ | |
514 | HW_INIT(ID_UPPER) \ | |
515 | HW_CLEANUP(ID_UPPER) \ | |
516 | HW_SCAN(ID_UPPER) \ | |
517 | HW_DEV_LIST(ID_UPPER) \ | |
518 | HW_DEV_CLEAR(ID_UPPER) \ | |
519 | HW_DEV_ACQUISITION_START(ID_UPPER) \ | |
520 | SR_PRIV struct sr_dev_driver ID##_driver_info = { \ | |
521 | .name = NAME, \ | |
522 | .longname = LONGNAME, \ | |
523 | .api_version = 1, \ | |
524 | .init = init_##ID_UPPER, \ | |
525 | .cleanup = cleanup_##ID_UPPER, \ | |
526 | .scan = scan_##ID_UPPER, \ | |
527 | .dev_list = dev_list_##ID_UPPER, \ | |
528 | .dev_clear = dev_clear_##ID_UPPER, \ | |
529 | .config_get = NULL, \ | |
530 | .config_set = config_set, \ | |
531 | .config_list = config_list, \ | |
532 | .dev_open = dev_open, \ | |
533 | .dev_close = std_serial_dev_close, \ | |
534 | .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \ | |
535 | .dev_acquisition_stop = dev_acquisition_stop, \ | |
536 | .priv = NULL, \ | |
537 | }; | |
538 | ||
539 | DRV(digitek_dt4000zc, DIGITEK_DT4000ZC, "digitek-dt4000zc", "Digitek DT4000ZC") | |
540 | DRV(tekpower_tp4000zc, TEKPOWER_TP4000ZC, "tekpower-tp4000zc", "TekPower TP4000ZC") | |
541 | DRV(metex_me31, METEX_ME31, "metex-me31", "Metex ME-31") | |
542 | DRV(peaktech_3410, PEAKTECH_3410, "peaktech-3410", "PeakTech 3410") | |
543 | DRV(mastech_mas345, MASTECH_MAS345, "mastech-mas345", "MASTECH MAS345") | |
544 | DRV(va_va18b, VA_VA18B, "va-va18b", "V&A VA18B") | |
545 | DRV(metex_m3640d, METEX_M3640D, "metex-m3640d", "Metex M-3640D") | |
546 | DRV(metex_m4650cr, METEX_M4650CR, "metex-m4650cr", "Metex M-4650CR") | |
547 | DRV(peaktech_4370, PEAKTECH_4370, "peaktech-4370", "PeakTech 4370") | |
548 | DRV(pce_pce_dm32, PCE_PCE_DM32, "pce-pce-dm32", "PCE PCE-DM32") | |
549 | DRV(radioshack_22_168, RADIOSHACK_22_168, "radioshack-22-168", "RadioShack 22-168") | |
550 | DRV(radioshack_22_805, RADIOSHACK_22_805, "radioshack-22-805", "RadioShack 22-805") | |
551 | DRV(radioshack_22_812, RADIOSHACK_22_812, "radioshack-22-812", "RadioShack 22-812") | |
552 | DRV(tecpel_dmm_8061_ser, TECPEL_DMM_8061_SER, "tecpel-dmm-8061-ser", "Tecpel DMM-8061 (UT-D02 cable)") | |
553 | DRV(voltcraft_m3650d, VOLTCRAFT_M3650D, "voltcraft-m3650d", "Voltcraft M-3650D") | |
554 | DRV(voltcraft_m4650cr, VOLTCRAFT_M4650CR, "voltcraft-m4650cr", "Voltcraft M-4650CR") | |
555 | DRV(voltcraft_vc820_ser, VOLTCRAFT_VC820_SER, "voltcraft-vc820-ser", "Voltcraft VC-820 (UT-D02 cable)") | |
556 | DRV(voltcraft_vc830_ser, VOLTCRAFT_VC830_SER, "voltcraft-vc830-ser", "Voltcraft VC-830 (UT-D02 cable)") | |
557 | DRV(voltcraft_vc840_ser, VOLTCRAFT_VC840_SER, "voltcraft-vc840-ser", "Voltcraft VC-840 (UT-D02 cable)") | |
558 | DRV(uni_t_ut60a_ser, UNI_T_UT60A_SER, "uni-t-ut60a-ser", "UNI-T UT60A (UT-D02 cable)") | |
559 | DRV(uni_t_ut60e_ser, UNI_T_UT60E_SER, "uni-t-ut60e-ser", "UNI-T UT60E (UT-D02 cable)") | |
560 | DRV(uni_t_ut61d_ser, UNI_T_UT61D_SER, "uni-t-ut61d-ser", "UNI-T UT61D (UT-D02 cable)") | |
561 | DRV(uni_t_ut61e_ser, UNI_T_UT61E_SER, "uni-t-ut61e-ser", "UNI-T UT61E (UT-D02 cable)") | |
562 | DRV(iso_tech_idm103n, ISO_TECH_IDM103N, "iso-tech-idm103n", "ISO-TECH IDM103N") |