]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2011-2015 Uwe Hermann <uwe@hermann-uwe.de> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #include <config.h> | |
22 | #include "protocol.h" | |
23 | ||
24 | SR_PRIV struct sr_dev_driver chronovu_la_driver_info; | |
25 | static struct sr_dev_driver *di = &chronovu_la_driver_info; | |
26 | ||
27 | static const uint32_t drvopts[] = { | |
28 | SR_CONF_LOGIC_ANALYZER, | |
29 | }; | |
30 | ||
31 | static const uint32_t scanopts[] = { | |
32 | SR_CONF_CONN, | |
33 | }; | |
34 | ||
35 | static const uint32_t devopts[] = { | |
36 | SR_CONF_LIMIT_MSEC | SR_CONF_SET, | |
37 | SR_CONF_LIMIT_SAMPLES | SR_CONF_SET | SR_CONF_LIST, | |
38 | SR_CONF_CONN | SR_CONF_GET, | |
39 | SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
40 | SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, | |
41 | }; | |
42 | ||
43 | static const int32_t trigger_matches[] = { | |
44 | SR_TRIGGER_ZERO, | |
45 | SR_TRIGGER_ONE, | |
46 | SR_TRIGGER_RISING, | |
47 | SR_TRIGGER_FALLING, | |
48 | }; | |
49 | ||
50 | static int dev_acquisition_stop(struct sr_dev_inst *sdi); | |
51 | ||
52 | static void clear_helper(void *priv) | |
53 | { | |
54 | struct dev_context *devc; | |
55 | ||
56 | devc = priv; | |
57 | ||
58 | ftdi_free(devc->ftdic); | |
59 | g_free(devc->final_buf); | |
60 | } | |
61 | ||
62 | static int dev_clear(const struct sr_dev_driver *di) | |
63 | { | |
64 | return std_dev_clear(di, clear_helper); | |
65 | } | |
66 | ||
67 | static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) | |
68 | { | |
69 | return std_init(sr_ctx, di, LOG_PREFIX); | |
70 | } | |
71 | ||
72 | static int add_device(int model, struct libusb_device_descriptor *des, | |
73 | const char *serial_num, const char *connection_id, | |
74 | libusb_device *usbdev, GSList **devices) | |
75 | { | |
76 | int ret; | |
77 | unsigned int i; | |
78 | struct sr_dev_inst *sdi; | |
79 | struct drv_context *drvc; | |
80 | struct dev_context *devc; | |
81 | ||
82 | ret = SR_OK; | |
83 | ||
84 | drvc = di->context; | |
85 | ||
86 | /* Allocate memory for our private device context. */ | |
87 | devc = g_malloc0(sizeof(struct dev_context)); | |
88 | ||
89 | /* Set some sane defaults. */ | |
90 | devc->prof = &cv_profiles[model]; | |
91 | devc->ftdic = NULL; /* Will be set in the open() API call. */ | |
92 | devc->cur_samplerate = 0; /* Set later (different for LA8/LA16). */ | |
93 | devc->limit_msec = 0; | |
94 | devc->limit_samples = 0; | |
95 | memset(devc->mangled_buf, 0, BS); | |
96 | devc->final_buf = NULL; | |
97 | devc->trigger_pattern = 0x0000; /* Irrelevant, see trigger_mask. */ | |
98 | devc->trigger_mask = 0x0000; /* All channels: "don't care". */ | |
99 | devc->trigger_edgemask = 0x0000; /* All channels: "state triggered". */ | |
100 | devc->trigger_found = 0; | |
101 | devc->done = 0; | |
102 | devc->block_counter = 0; | |
103 | devc->divcount = 0; | |
104 | devc->usb_vid = des->idVendor; | |
105 | devc->usb_pid = des->idProduct; | |
106 | memset(devc->samplerates, 0, sizeof(uint64_t) * 255); | |
107 | ||
108 | /* Allocate memory where we'll store the de-mangled data. */ | |
109 | if (!(devc->final_buf = g_try_malloc(SDRAM_SIZE))) { | |
110 | sr_err("Failed to allocate memory for sample buffer."); | |
111 | ret = SR_ERR_MALLOC; | |
112 | goto err_free_devc; | |
113 | } | |
114 | ||
115 | /* We now know the device, set its max. samplerate as default. */ | |
116 | devc->cur_samplerate = devc->prof->max_samplerate; | |
117 | ||
118 | /* Register the device with libsigrok. */ | |
119 | sdi = g_malloc0(sizeof(struct sr_dev_inst)); | |
120 | sdi->status = SR_ST_INITIALIZING; | |
121 | sdi->vendor = g_strdup("ChronoVu"); | |
122 | sdi->model = g_strdup(devc->prof->modelname); | |
123 | sdi->serial_num = g_strdup(serial_num); | |
124 | sdi->connection_id = g_strdup(connection_id); | |
125 | sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(usbdev), | |
126 | libusb_get_device_address(usbdev), NULL); | |
127 | sdi->driver = di; | |
128 | sdi->priv = devc; | |
129 | ||
130 | for (i = 0; i < devc->prof->num_channels; i++) | |
131 | sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, | |
132 | cv_channel_names[i]); | |
133 | ||
134 | *devices = g_slist_append(*devices, sdi); | |
135 | drvc->instances = g_slist_append(drvc->instances, sdi); | |
136 | ||
137 | if (ret == SR_OK) | |
138 | return SR_OK; | |
139 | ||
140 | err_free_devc: | |
141 | g_free(devc); | |
142 | ||
143 | return ret; | |
144 | } | |
145 | ||
146 | static GSList *scan(struct sr_dev_driver *di, GSList *options) | |
147 | { | |
148 | int i, ret, model; | |
149 | struct drv_context *drvc; | |
150 | GSList *devices, *conn_devices, *l; | |
151 | struct sr_usb_dev_inst *usb; | |
152 | struct sr_config *src; | |
153 | struct libusb_device_descriptor des; | |
154 | libusb_device **devlist; | |
155 | struct libusb_device_handle *hdl; | |
156 | const char *conn; | |
157 | char product[64], serial_num[64], connection_id[64]; | |
158 | ||
159 | drvc = di->context; | |
160 | drvc->instances = NULL; | |
161 | ||
162 | conn = NULL; | |
163 | for (l = options; l; l = l->next) { | |
164 | src = l->data; | |
165 | switch (src->key) { | |
166 | case SR_CONF_CONN: | |
167 | conn = g_variant_get_string(src->data, NULL); | |
168 | break; | |
169 | } | |
170 | } | |
171 | if (conn) | |
172 | conn_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn); | |
173 | else | |
174 | conn_devices = NULL; | |
175 | ||
176 | devices = NULL; | |
177 | libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist); | |
178 | ||
179 | for (i = 0; devlist[i]; i++) { | |
180 | if (conn) { | |
181 | for (l = conn_devices; l; l = l->next) { | |
182 | usb = l->data; | |
183 | if (usb->bus == libusb_get_bus_number(devlist[i]) | |
184 | && usb->address == libusb_get_device_address(devlist[i])) | |
185 | break; | |
186 | } | |
187 | if (!l) | |
188 | /* This device matched none of the ones that | |
189 | * matched the conn specification. */ | |
190 | continue; | |
191 | } | |
192 | ||
193 | libusb_get_device_descriptor(devlist[i], &des); | |
194 | ||
195 | if ((ret = libusb_open(devlist[i], &hdl)) < 0) | |
196 | continue; | |
197 | ||
198 | if (des.iProduct == 0) { | |
199 | product[0] = '\0'; | |
200 | } else if ((ret = libusb_get_string_descriptor_ascii(hdl, | |
201 | des.iProduct, (unsigned char *)product, | |
202 | sizeof(product))) < 0) { | |
203 | sr_warn("Failed to get product string descriptor: %s.", | |
204 | libusb_error_name(ret)); | |
205 | continue; | |
206 | } | |
207 | ||
208 | if (des.iSerialNumber == 0) { | |
209 | serial_num[0] = '\0'; | |
210 | } else if ((ret = libusb_get_string_descriptor_ascii(hdl, | |
211 | des.iSerialNumber, (unsigned char *)serial_num, | |
212 | sizeof(serial_num))) < 0) { | |
213 | sr_warn("Failed to get serial number string descriptor: %s.", | |
214 | libusb_error_name(ret)); | |
215 | continue; | |
216 | } | |
217 | ||
218 | usb_get_port_path(devlist[i], connection_id, sizeof(connection_id)); | |
219 | ||
220 | libusb_close(hdl); | |
221 | ||
222 | if (!strcmp(product, "ChronoVu LA8")) { | |
223 | model = 0; | |
224 | } else if (!strcmp(product, "ChronoVu LA16")) { | |
225 | model = 1; | |
226 | } else { | |
227 | sr_spew("Unknown iProduct string '%s'.", product); | |
228 | continue; | |
229 | } | |
230 | ||
231 | sr_dbg("Found %s (%04x:%04x, %d.%d, %s).", | |
232 | product, des.idVendor, des.idProduct, | |
233 | libusb_get_bus_number(devlist[i]), | |
234 | libusb_get_device_address(devlist[i]), connection_id); | |
235 | ||
236 | if ((ret = add_device(model, &des, serial_num, connection_id, | |
237 | devlist[i], &devices)) < 0) { | |
238 | sr_dbg("Failed to add device: %d.", ret); | |
239 | } | |
240 | } | |
241 | ||
242 | libusb_free_device_list(devlist, 1); | |
243 | g_slist_free_full(conn_devices, (GDestroyNotify)sr_usb_dev_inst_free); | |
244 | ||
245 | return devices; | |
246 | } | |
247 | ||
248 | static GSList *dev_list(const struct sr_dev_driver *di) | |
249 | { | |
250 | return ((struct drv_context *)(di->context))->instances; | |
251 | } | |
252 | ||
253 | static int dev_open(struct sr_dev_inst *sdi) | |
254 | { | |
255 | struct dev_context *devc; | |
256 | int ret; | |
257 | ||
258 | devc = sdi->priv; | |
259 | ||
260 | /* Allocate memory for the FTDI context and initialize it. */ | |
261 | if (!(devc->ftdic = ftdi_new())) { | |
262 | sr_err("Failed to initialize libftdi."); | |
263 | return SR_ERR; | |
264 | } | |
265 | ||
266 | sr_dbg("Opening %s device (%04x:%04x).", devc->prof->modelname, | |
267 | devc->usb_vid, devc->usb_pid); | |
268 | ||
269 | /* Open the device. */ | |
270 | if ((ret = ftdi_usb_open_desc(devc->ftdic, devc->usb_vid, | |
271 | devc->usb_pid, devc->prof->iproduct, NULL)) < 0) { | |
272 | sr_err("Failed to open FTDI device (%d): %s.", | |
273 | ret, ftdi_get_error_string(devc->ftdic)); | |
274 | goto err_ftdi_free; | |
275 | } | |
276 | sr_dbg("Device opened successfully."); | |
277 | ||
278 | /* Purge RX/TX buffers in the FTDI chip. */ | |
279 | if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { | |
280 | sr_err("Failed to purge FTDI buffers (%d): %s.", | |
281 | ret, ftdi_get_error_string(devc->ftdic)); | |
282 | goto err_ftdi_free; | |
283 | } | |
284 | sr_dbg("FTDI buffers purged successfully."); | |
285 | ||
286 | /* Enable flow control in the FTDI chip. */ | |
287 | if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) { | |
288 | sr_err("Failed to enable FTDI flow control (%d): %s.", | |
289 | ret, ftdi_get_error_string(devc->ftdic)); | |
290 | goto err_ftdi_free; | |
291 | } | |
292 | sr_dbg("FTDI flow control enabled successfully."); | |
293 | ||
294 | /* Wait 100ms. */ | |
295 | g_usleep(100 * 1000); | |
296 | ||
297 | sdi->status = SR_ST_ACTIVE; | |
298 | ||
299 | if (ret == SR_OK) | |
300 | return SR_OK; | |
301 | ||
302 | err_ftdi_free: | |
303 | ftdi_free(devc->ftdic); /* Close device (if open), free FTDI context. */ | |
304 | devc->ftdic = NULL; | |
305 | return ret; | |
306 | } | |
307 | ||
308 | static int dev_close(struct sr_dev_inst *sdi) | |
309 | { | |
310 | int ret; | |
311 | struct dev_context *devc; | |
312 | ||
313 | if (sdi->status != SR_ST_ACTIVE) | |
314 | return SR_OK; | |
315 | ||
316 | devc = sdi->priv; | |
317 | ||
318 | if (devc->ftdic && (ret = ftdi_usb_close(devc->ftdic)) < 0) | |
319 | sr_err("Failed to close FTDI device (%d): %s.", | |
320 | ret, ftdi_get_error_string(devc->ftdic)); | |
321 | sdi->status = SR_ST_INACTIVE; | |
322 | ||
323 | return SR_OK; | |
324 | } | |
325 | ||
326 | static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, | |
327 | const struct sr_channel_group *cg) | |
328 | { | |
329 | struct dev_context *devc; | |
330 | struct sr_usb_dev_inst *usb; | |
331 | char str[128]; | |
332 | ||
333 | (void)cg; | |
334 | ||
335 | switch (key) { | |
336 | case SR_CONF_CONN: | |
337 | if (!sdi || !(usb = sdi->conn)) | |
338 | return SR_ERR_ARG; | |
339 | snprintf(str, 128, "%d.%d", usb->bus, usb->address); | |
340 | *data = g_variant_new_string(str); | |
341 | break; | |
342 | case SR_CONF_SAMPLERATE: | |
343 | if (!sdi || !(devc = sdi->priv)) | |
344 | return SR_ERR_BUG; | |
345 | *data = g_variant_new_uint64(devc->cur_samplerate); | |
346 | break; | |
347 | default: | |
348 | return SR_ERR_NA; | |
349 | } | |
350 | ||
351 | return SR_OK; | |
352 | } | |
353 | ||
354 | static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, | |
355 | const struct sr_channel_group *cg) | |
356 | { | |
357 | struct dev_context *devc; | |
358 | ||
359 | (void)cg; | |
360 | ||
361 | if (sdi->status != SR_ST_ACTIVE) | |
362 | return SR_ERR_DEV_CLOSED; | |
363 | ||
364 | if (!(devc = sdi->priv)) | |
365 | return SR_ERR_BUG; | |
366 | ||
367 | switch (key) { | |
368 | case SR_CONF_SAMPLERATE: | |
369 | if (cv_set_samplerate(sdi, g_variant_get_uint64(data)) < 0) | |
370 | return SR_ERR; | |
371 | break; | |
372 | case SR_CONF_LIMIT_MSEC: | |
373 | if (g_variant_get_uint64(data) == 0) | |
374 | return SR_ERR_ARG; | |
375 | devc->limit_msec = g_variant_get_uint64(data); | |
376 | break; | |
377 | case SR_CONF_LIMIT_SAMPLES: | |
378 | if (g_variant_get_uint64(data) == 0) | |
379 | return SR_ERR_ARG; | |
380 | devc->limit_samples = g_variant_get_uint64(data); | |
381 | break; | |
382 | default: | |
383 | return SR_ERR_NA; | |
384 | } | |
385 | ||
386 | return SR_OK; | |
387 | } | |
388 | ||
389 | static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, | |
390 | const struct sr_channel_group *cg) | |
391 | { | |
392 | GVariant *gvar, *grange[2]; | |
393 | GVariantBuilder gvb; | |
394 | struct dev_context *devc; | |
395 | ||
396 | (void)cg; | |
397 | ||
398 | switch (key) { | |
399 | case SR_CONF_SCAN_OPTIONS: | |
400 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, | |
401 | scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); | |
402 | break; | |
403 | case SR_CONF_DEVICE_OPTIONS: | |
404 | if (!sdi) | |
405 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, | |
406 | drvopts, ARRAY_SIZE(drvopts), sizeof(uint32_t)); | |
407 | else | |
408 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, | |
409 | devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); | |
410 | break; | |
411 | case SR_CONF_SAMPLERATE: | |
412 | if (!sdi || !sdi->priv || !(devc = sdi->priv)) | |
413 | return SR_ERR_BUG; | |
414 | cv_fill_samplerates_if_needed(sdi); | |
415 | g_variant_builder_init(&gvb, G_VARIANT_TYPE("a{sv}")); | |
416 | gvar = g_variant_new_fixed_array(G_VARIANT_TYPE("t"), | |
417 | devc->samplerates, | |
418 | ARRAY_SIZE(devc->samplerates), | |
419 | sizeof(uint64_t)); | |
420 | g_variant_builder_add(&gvb, "{sv}", "samplerates", gvar); | |
421 | *data = g_variant_builder_end(&gvb); | |
422 | break; | |
423 | case SR_CONF_LIMIT_SAMPLES: | |
424 | if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof) | |
425 | return SR_ERR_BUG; | |
426 | grange[0] = g_variant_new_uint64(0); | |
427 | if (devc->prof->model == CHRONOVU_LA8) | |
428 | grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES); | |
429 | else | |
430 | grange[1] = g_variant_new_uint64(MAX_NUM_SAMPLES / 2); | |
431 | *data = g_variant_new_tuple(grange, 2); | |
432 | break; | |
433 | case SR_CONF_TRIGGER_MATCH: | |
434 | if (!sdi || !sdi->priv || !(devc = sdi->priv) || !devc->prof) | |
435 | return SR_ERR_BUG; | |
436 | *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, | |
437 | trigger_matches, devc->prof->num_trigger_matches, | |
438 | sizeof(int32_t)); | |
439 | break; | |
440 | default: | |
441 | return SR_ERR_NA; | |
442 | } | |
443 | ||
444 | return SR_OK; | |
445 | } | |
446 | ||
447 | static int receive_data(int fd, int revents, void *cb_data) | |
448 | { | |
449 | int i, ret; | |
450 | struct sr_dev_inst *sdi; | |
451 | struct dev_context *devc; | |
452 | ||
453 | (void)fd; | |
454 | (void)revents; | |
455 | ||
456 | if (!(sdi = cb_data)) { | |
457 | sr_err("cb_data was NULL."); | |
458 | return FALSE; | |
459 | } | |
460 | ||
461 | if (!(devc = sdi->priv)) { | |
462 | sr_err("sdi->priv was NULL."); | |
463 | return FALSE; | |
464 | } | |
465 | ||
466 | if (!devc->ftdic) { | |
467 | sr_err("devc->ftdic was NULL."); | |
468 | return FALSE; | |
469 | } | |
470 | ||
471 | /* Get one block of data. */ | |
472 | if ((ret = cv_read_block(devc)) < 0) { | |
473 | sr_err("Failed to read data block: %d.", ret); | |
474 | dev_acquisition_stop(sdi); | |
475 | return FALSE; | |
476 | } | |
477 | ||
478 | /* We need to get exactly NUM_BLOCKS blocks (i.e. 8MB) of data. */ | |
479 | if (devc->block_counter != (NUM_BLOCKS - 1)) { | |
480 | devc->block_counter++; | |
481 | return TRUE; | |
482 | } | |
483 | ||
484 | sr_dbg("Sampling finished, sending data to session bus now."); | |
485 | ||
486 | /* | |
487 | * All data was received and demangled, send it to the session bus. | |
488 | * | |
489 | * Note: Due to the method how data is spread across the 8MByte of | |
490 | * SDRAM, we can _not_ send it to the session bus in a streaming | |
491 | * manner while we receive it. We have to receive and de-mangle the | |
492 | * full 8MByte first, only then the whole buffer contains valid data. | |
493 | */ | |
494 | for (i = 0; i < NUM_BLOCKS; i++) | |
495 | cv_send_block_to_session_bus(sdi, i); | |
496 | ||
497 | dev_acquisition_stop(sdi); | |
498 | ||
499 | return TRUE; | |
500 | } | |
501 | ||
502 | static int dev_acquisition_start(const struct sr_dev_inst *sdi) | |
503 | { | |
504 | struct dev_context *devc; | |
505 | uint8_t buf[8]; | |
506 | int bytes_to_write, bytes_written; | |
507 | ||
508 | if (sdi->status != SR_ST_ACTIVE) | |
509 | return SR_ERR_DEV_CLOSED; | |
510 | ||
511 | devc = sdi->priv; | |
512 | ||
513 | if (!devc->ftdic) { | |
514 | sr_err("devc->ftdic was NULL."); | |
515 | return SR_ERR_BUG; | |
516 | } | |
517 | ||
518 | devc->divcount = cv_samplerate_to_divcount(sdi, devc->cur_samplerate); | |
519 | if (devc->divcount == 0xff) { | |
520 | sr_err("Invalid divcount/samplerate."); | |
521 | return SR_ERR; | |
522 | } | |
523 | ||
524 | if (cv_convert_trigger(sdi) != SR_OK) { | |
525 | sr_err("Failed to configure trigger."); | |
526 | return SR_ERR; | |
527 | } | |
528 | ||
529 | /* Fill acquisition parameters into buf[]. */ | |
530 | if (devc->prof->model == CHRONOVU_LA8) { | |
531 | buf[0] = devc->divcount; | |
532 | buf[1] = 0xff; /* This byte must always be 0xff. */ | |
533 | buf[2] = devc->trigger_pattern & 0xff; | |
534 | buf[3] = devc->trigger_mask & 0xff; | |
535 | bytes_to_write = 4; | |
536 | } else { | |
537 | buf[0] = devc->divcount; | |
538 | buf[1] = 0xff; /* This byte must always be 0xff. */ | |
539 | buf[2] = (devc->trigger_pattern & 0xff00) >> 8; /* LSB */ | |
540 | buf[3] = (devc->trigger_pattern & 0x00ff) >> 0; /* MSB */ | |
541 | buf[4] = (devc->trigger_mask & 0xff00) >> 8; /* LSB */ | |
542 | buf[5] = (devc->trigger_mask & 0x00ff) >> 0; /* MSB */ | |
543 | buf[6] = (devc->trigger_edgemask & 0xff00) >> 8; /* LSB */ | |
544 | buf[7] = (devc->trigger_edgemask & 0x00ff) >> 0; /* MSB */ | |
545 | bytes_to_write = 8; | |
546 | } | |
547 | ||
548 | /* Start acquisition. */ | |
549 | bytes_written = cv_write(devc, buf, bytes_to_write); | |
550 | ||
551 | if (bytes_written < 0 || bytes_written != bytes_to_write) { | |
552 | sr_err("Acquisition failed to start."); | |
553 | return SR_ERR; | |
554 | } | |
555 | ||
556 | sr_dbg("Hardware acquisition started successfully."); | |
557 | ||
558 | std_session_send_df_header(sdi, LOG_PREFIX); | |
559 | ||
560 | /* Time when we should be done (for detecting trigger timeouts). */ | |
561 | devc->done = (devc->divcount + 1) * devc->prof->trigger_constant + | |
562 | g_get_monotonic_time() + (10 * G_TIME_SPAN_SECOND); | |
563 | devc->block_counter = 0; | |
564 | devc->trigger_found = 0; | |
565 | ||
566 | /* Hook up a dummy handler to receive data from the device. */ | |
567 | sr_session_source_add(sdi->session, -1, 0, 0, receive_data, (void *)sdi); | |
568 | ||
569 | return SR_OK; | |
570 | } | |
571 | ||
572 | static int dev_acquisition_stop(struct sr_dev_inst *sdi) | |
573 | { | |
574 | sr_dbg("Stopping acquisition."); | |
575 | sr_session_source_remove(sdi->session, -1); | |
576 | std_session_send_df_end(sdi, LOG_PREFIX); | |
577 | ||
578 | return SR_OK; | |
579 | } | |
580 | ||
581 | SR_PRIV struct sr_dev_driver chronovu_la_driver_info = { | |
582 | .name = "chronovu-la", | |
583 | .longname = "ChronoVu LA8/LA16", | |
584 | .api_version = 1, | |
585 | .init = init, | |
586 | .cleanup = std_cleanup, | |
587 | .scan = scan, | |
588 | .dev_list = dev_list, | |
589 | .dev_clear = dev_clear, | |
590 | .config_get = config_get, | |
591 | .config_set = config_set, | |
592 | .config_list = config_list, | |
593 | .dev_open = dev_open, | |
594 | .dev_close = dev_close, | |
595 | .dev_acquisition_start = dev_acquisition_start, | |
596 | .dev_acquisition_stop = dev_acquisition_stop, | |
597 | .context = NULL, | |
598 | }; |