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