]> sigrok.org Git - libsigrok.git/blame - src/hardware/yokogawa-dlm/api.c
drivers: Drop some unnecessary prefixes.
[libsigrok.git] / src / hardware / yokogawa-dlm / api.c
CommitLineData
10763937
SA
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2014 abraxa (Soeren Apel) <soeren@apelpie.net>
5 * Based on the Hameg HMO driver by poljar (Damir Jelić) <poljarinho@gmail.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
6ec6c43b 21#include <config.h>
10763937 22#include <stdlib.h>
5a1afc09 23#include "scpi.h"
10763937
SA
24#include "protocol.h"
25
dd5c48a6 26static struct sr_dev_driver yokogawa_dlm_driver_info;
8ab929d6 27
329733d9
UH
28static const char *MANUFACTURER_ID = "YOKOGAWA";
29static const char *MANUFACTURER_NAME = "Yokogawa";
8ab929d6 30
4b25cbff 31static const uint32_t scanopts[] = {
f3c60fb6
SA
32 SR_CONF_CONN,
33};
34
4b25cbff 35static const uint32_t drvopts[] = {
cf0280fa
AJ
36 SR_CONF_LOGIC_ANALYZER,
37 SR_CONF_OSCILLOSCOPE,
38};
39
4b25cbff 40static const uint32_t devopts[] = {
f3c60fb6
SA
41 SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,
42 SR_CONF_SAMPLERATE | SR_CONF_GET,
43 SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
44 SR_CONF_NUM_HDIV | SR_CONF_GET,
45 SR_CONF_HORIZ_TRIGGERPOS | SR_CONF_GET | SR_CONF_SET,
f3c60fb6 46 SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
86621306 47 SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
f3c60fb6
SA
48};
49
4b25cbff 50static const uint32_t analog_devopts[] = {
f3c60fb6 51 SR_CONF_NUM_VDIV | SR_CONF_GET,
86621306
UH
52 SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
53 SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
f3c60fb6
SA
54};
55
4b25cbff 56static const uint32_t digital_devopts[] = {
f3c60fb6
SA
57};
58
8ab929d6
SA
59enum {
60 CG_INVALID = -1,
61 CG_NONE,
62 CG_ANALOG,
63 CG_DIGITAL,
64};
65
8ab929d6
SA
66static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
67{
68 struct sr_dev_inst *sdi;
69 struct dev_context *devc;
70 struct sr_scpi_hw_info *hw_info;
71 char *model_name;
72 int model_index;
73
74 sdi = NULL;
75 devc = NULL;
76 hw_info = NULL;
77
78 if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
79 sr_info("Couldn't get IDN response.");
80 goto fail;
81 }
82
83 if (strcmp(hw_info->manufacturer, MANUFACTURER_ID) != 0)
84 goto fail;
85
86 if (dlm_model_get(hw_info->model, &model_name, &model_index) != SR_OK)
87 goto fail;
88
aac29cc1 89 sdi = g_malloc0(sizeof(struct sr_dev_inst));
0af636be
UH
90 sdi->vendor = g_strdup(MANUFACTURER_NAME);
91 sdi->model = g_strdup(model_name);
92 sdi->version = g_strdup(hw_info->firmware_version);
8ab929d6 93
d1314831
SA
94 sdi->serial_num = g_strdup(hw_info->serial_number);
95
8ab929d6
SA
96 sr_scpi_hw_info_free(hw_info);
97 hw_info = NULL;
98
ac10a927 99 devc = g_malloc0(sizeof(struct dev_context));
8ab929d6 100
4f840ce9 101 sdi->driver = &yokogawa_dlm_driver_info;
8ab929d6
SA
102 sdi->priv = devc;
103 sdi->inst_type = SR_INST_SCPI;
104 sdi->conn = scpi;
105
106 if (dlm_device_init(sdi, model_index) != SR_OK)
107 goto fail;
108
8ab929d6
SA
109 return sdi;
110
111fail:
7b365c47 112 sr_scpi_hw_info_free(hw_info);
4bf93988 113 sr_dev_inst_free(sdi);
b1f83103 114 g_free(devc);
8ab929d6
SA
115
116 return NULL;
117}
118
4f840ce9 119static GSList *scan(struct sr_dev_driver *di, GSList *options)
8ab929d6 120{
41812aca 121 return sr_scpi_scan(di->context, options, probe_usbtmc_device);
8ab929d6
SA
122}
123
3553451f 124static void clear_helper(struct dev_context *devc)
8ab929d6 125{
8ab929d6 126 dlm_scope_state_destroy(devc->model_state);
8ab929d6
SA
127 g_free(devc->analog_groups);
128 g_free(devc->digital_groups);
8ab929d6
SA
129}
130
4f840ce9 131static int dev_clear(const struct sr_dev_driver *di)
8ab929d6 132{
3553451f 133 return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
8ab929d6
SA
134}
135
136static int dev_open(struct sr_dev_inst *sdi)
137{
6402c379 138 if (sr_scpi_open(sdi->conn) != SR_OK)
8ab929d6
SA
139 return SR_ERR;
140
141 if (dlm_scope_state_query(sdi) != SR_OK)
142 return SR_ERR;
143
8ab929d6
SA
144 return SR_OK;
145}
146
147static int dev_close(struct sr_dev_inst *sdi)
148{
f1ba6b4b 149 return sr_scpi_close(sdi->conn);
8ab929d6
SA
150}
151
8ab929d6
SA
152/**
153 * Check which category a given channel group belongs to.
154 *
155 * @param devc Our internal device context.
a9308652 156 * @param cg The channel group to check.
8ab929d6 157 *
a9308652
UH
158 * @retval CG_NONE cg is NULL
159 * @retval CG_ANALOG cg is an analog group
8ab929d6
SA
160 * @retval CG_DIGITAL cg is a digital group
161 * @retval CG_INVALID cg is something else
162 */
163static int check_channel_group(struct dev_context *devc,
ac10a927 164 const struct sr_channel_group *cg)
8ab929d6
SA
165{
166 unsigned int i;
329733d9 167 const struct scope_config *model;
8ab929d6
SA
168
169 model = devc->model_config;
170
171 if (!cg)
172 return CG_NONE;
173
a9308652 174 for (i = 0; i < model->analog_channels; i++)
8ab929d6
SA
175 if (cg == devc->analog_groups[i])
176 return CG_ANALOG;
177
a9308652 178 for (i = 0; i < model->pods; i++)
8ab929d6
SA
179 if (cg == devc->digital_groups[i])
180 return CG_DIGITAL;
181
182 sr_err("Invalid channel group specified.");
183 return CG_INVALID;
184}
185
584560f1 186static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
ac10a927 187 const struct sr_channel_group *cg)
8ab929d6
SA
188{
189 int ret, cg_type;
190 unsigned int i;
191 struct dev_context *devc;
329733d9 192 const struct scope_config *model;
8ab929d6
SA
193 struct scope_state *state;
194
709468ba 195 if (!sdi)
8ab929d6
SA
196 return SR_ERR_ARG;
197
709468ba
UH
198 devc = sdi->priv;
199
8ab929d6
SA
200 if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
201 return SR_ERR;
202
8ab929d6
SA
203 model = devc->model_config;
204 state = devc->model_state;
205
206 switch (key) {
bf622e6d 207 case SR_CONF_NUM_HDIV:
8ab929d6
SA
208 *data = g_variant_new_int32(model->num_xdivs);
209 ret = SR_OK;
210 break;
211 case SR_CONF_TIMEBASE:
212 *data = g_variant_new("(tt)",
f3c60fb6
SA
213 dlm_timebases[state->timebase][0],
214 dlm_timebases[state->timebase][1]);
8ab929d6
SA
215 ret = SR_OK;
216 break;
217 case SR_CONF_NUM_VDIV:
218 if (cg_type == CG_NONE) {
219 sr_err("No channel group specified.");
220 return SR_ERR_CHANNEL_GROUP;
221 } else if (cg_type == CG_ANALOG) {
222 *data = g_variant_new_int32(model->num_ydivs);
223 ret = SR_OK;
224 break;
225 } else {
226 ret = SR_ERR_NA;
227 }
228 break;
229 case SR_CONF_VDIV:
230 ret = SR_ERR_NA;
231 if (cg_type == CG_NONE) {
232 sr_err("No channel group specified.");
233 return SR_ERR_CHANNEL_GROUP;
234 } else if (cg_type != CG_ANALOG)
235 break;
236
a9308652 237 for (i = 0; i < model->analog_channels; i++) {
8ab929d6
SA
238 if (cg != devc->analog_groups[i])
239 continue;
240 *data = g_variant_new("(tt)",
f3c60fb6
SA
241 dlm_vdivs[state->analog_states[i].vdiv][0],
242 dlm_vdivs[state->analog_states[i].vdiv][1]);
8ab929d6
SA
243 ret = SR_OK;
244 break;
245 }
246 break;
247 case SR_CONF_TRIGGER_SOURCE:
248 *data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
249 ret = SR_OK;
250 break;
251 case SR_CONF_TRIGGER_SLOPE:
f3c60fb6 252 *data = g_variant_new_string(dlm_trigger_slopes[state->trigger_slope]);
8ab929d6
SA
253 ret = SR_OK;
254 break;
255 case SR_CONF_HORIZ_TRIGGERPOS:
256 *data = g_variant_new_double(state->horiz_triggerpos);
257 ret = SR_OK;
258 break;
259 case SR_CONF_COUPLING:
260 ret = SR_ERR_NA;
261 if (cg_type == CG_NONE) {
262 sr_err("No channel group specified.");
263 return SR_ERR_CHANNEL_GROUP;
264 } else if (cg_type != CG_ANALOG)
265 break;
266
a9308652 267 for (i = 0; i < model->analog_channels; i++) {
8ab929d6
SA
268 if (cg != devc->analog_groups[i])
269 continue;
270 *data = g_variant_new_string((*model->coupling_options)[state->analog_states[i].coupling]);
271 ret = SR_OK;
272 break;
273 }
274 break;
275 case SR_CONF_SAMPLERATE:
276 *data = g_variant_new_uint64(state->sample_rate);
277 ret = SR_OK;
278 break;
279 default:
280 ret = SR_ERR_NA;
281 }
282
283 return ret;
284}
285
286static GVariant *build_tuples(const uint64_t (*array)[][2], unsigned int n)
287{
288 unsigned int i;
289 GVariant *rational[2];
290 GVariantBuilder gvb;
291
292 g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
293
294 for (i = 0; i < n; i++) {
295 rational[0] = g_variant_new_uint64((*array)[i][0]);
296 rational[1] = g_variant_new_uint64((*array)[i][1]);
297
298 /* FIXME: Valgrind reports a memory leak here. */
299 g_variant_builder_add_value(&gvb, g_variant_new_tuple(rational, 2));
300 }
301
302 return g_variant_builder_end(&gvb);
303}
304
584560f1 305static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
ac10a927 306 const struct sr_channel_group *cg)
8ab929d6
SA
307{
308 int ret, cg_type;
309 unsigned int i, j;
310 char float_str[30];
311 struct dev_context *devc;
329733d9 312 const struct scope_config *model;
8ab929d6
SA
313 struct scope_state *state;
314 const char *tmp;
315 uint64_t p, q;
316 double tmp_d;
317 gboolean update_sample_rate;
318
319 if (!sdi || !(devc = sdi->priv))
320 return SR_ERR_ARG;
321
322 if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
323 return SR_ERR;
324
325 model = devc->model_config;
326 state = devc->model_state;
327 update_sample_rate = FALSE;
328
329 ret = SR_ERR_NA;
330
331 switch (key) {
332 case SR_CONF_LIMIT_FRAMES:
333 devc->frame_limit = g_variant_get_uint64(data);
334 ret = SR_OK;
335 break;
336 case SR_CONF_TRIGGER_SOURCE:
337 tmp = g_variant_get_string(data, NULL);
338 for (i = 0; (*model->trigger_sources)[i]; i++) {
339 if (g_strcmp0(tmp, (*model->trigger_sources)[i]) != 0)
340 continue;
341 state->trigger_source = i;
342 /* TODO: A and B trigger support possible? */
343 ret = dlm_trigger_source_set(sdi->conn, (*model->trigger_sources)[i]);
344 break;
345 }
346 break;
347 case SR_CONF_VDIV:
348 if (cg_type == CG_NONE) {
349 sr_err("No channel group specified.");
350 return SR_ERR_CHANNEL_GROUP;
351 }
352
353 g_variant_get(data, "(tt)", &p, &q);
354
f3c60fb6
SA
355 for (i = 0; i < ARRAY_SIZE(dlm_vdivs); i++) {
356 if (p != dlm_vdivs[i][0] ||
357 q != dlm_vdivs[i][1])
8ab929d6 358 continue;
a9308652 359 for (j = 1; j <= model->analog_channels; j++) {
8ab929d6
SA
360 if (cg != devc->analog_groups[j - 1])
361 continue;
362 state->analog_states[j - 1].vdiv = i;
363 g_ascii_formatd(float_str, sizeof(float_str),
364 "%E", (float) p / q);
365 if (dlm_analog_chan_vdiv_set(sdi->conn, j, float_str) != SR_OK ||
ac10a927 366 sr_scpi_get_opc(sdi->conn) != SR_OK)
8ab929d6
SA
367 return SR_ERR;
368
369 break;
370 }
371
372 ret = SR_OK;
373 break;
374 }
375 break;
376 case SR_CONF_TIMEBASE:
377 g_variant_get(data, "(tt)", &p, &q);
378
f3c60fb6
SA
379 for (i = 0; i < ARRAY_SIZE(dlm_timebases); i++) {
380 if (p != dlm_timebases[i][0] ||
381 q != dlm_timebases[i][1])
8ab929d6
SA
382 continue;
383 state->timebase = i;
384 g_ascii_formatd(float_str, sizeof(float_str),
385 "%E", (float) p / q);
386 ret = dlm_timebase_set(sdi->conn, float_str);
387 update_sample_rate = TRUE;
388 break;
389 }
390 break;
391 case SR_CONF_HORIZ_TRIGGERPOS:
392 tmp_d = g_variant_get_double(data);
393
394 /* TODO: Check if the calculation makes sense for the DLM. */
395 if (tmp_d < 0.0 || tmp_d > 1.0)
396 return SR_ERR;
397
398 state->horiz_triggerpos = tmp_d;
399 tmp_d = -(tmp_d - 0.5) *
f3c60fb6
SA
400 ((double) dlm_timebases[state->timebase][0] /
401 dlm_timebases[state->timebase][1])
ac10a927 402 * model->num_xdivs;
8ab929d6
SA
403
404 g_ascii_formatd(float_str, sizeof(float_str), "%E", tmp_d);
405 ret = dlm_horiz_trigger_pos_set(sdi->conn, float_str);
406 break;
407 case SR_CONF_TRIGGER_SLOPE:
408 tmp = g_variant_get_string(data, NULL);
409
410 if (!tmp || !(tmp[0] == 'f' || tmp[0] == 'r'))
411 return SR_ERR_ARG;
412
413 /* Note: See dlm_trigger_slopes[] in protocol.c. */
414 state->trigger_slope = (tmp[0] == 'r') ?
415 SLOPE_POSITIVE : SLOPE_NEGATIVE;
416
417 ret = dlm_trigger_slope_set(sdi->conn, state->trigger_slope);
418 break;
419 case SR_CONF_COUPLING:
420 if (cg_type == CG_NONE) {
421 sr_err("No channel group specified.");
422 return SR_ERR_CHANNEL_GROUP;
423 }
424
425 tmp = g_variant_get_string(data, NULL);
426
427 for (i = 0; (*model->coupling_options)[i]; i++) {
428 if (strcmp(tmp, (*model->coupling_options)[i]) != 0)
429 continue;
a9308652 430 for (j = 1; j <= model->analog_channels; j++) {
8ab929d6
SA
431 if (cg != devc->analog_groups[j - 1])
432 continue;
433 state->analog_states[j-1].coupling = i;
434
435 if (dlm_analog_chan_coupl_set(sdi->conn, j, tmp) != SR_OK ||
ac10a927 436 sr_scpi_get_opc(sdi->conn) != SR_OK)
8ab929d6
SA
437 return SR_ERR;
438 break;
439 }
440
441 ret = SR_OK;
442 break;
443 }
444 break;
445 default:
446 ret = SR_ERR_NA;
447 break;
448 }
449
450 if (ret == SR_OK)
451 ret = sr_scpi_get_opc(sdi->conn);
452
453 if (ret == SR_OK && update_sample_rate)
454 ret = dlm_sample_rate_query(sdi);
455
456 return ret;
457}
458
c65a021c
SA
459static int config_channel_set(const struct sr_dev_inst *sdi,
460 struct sr_channel *ch, unsigned int changes)
461{
a9308652 462 /* Currently we only handle SR_CHANNEL_SET_ENABLED. */
c65a021c
SA
463 if (changes != SR_CHANNEL_SET_ENABLED)
464 return SR_ERR_NA;
465
466 return dlm_channel_state_set(sdi, ch->index, ch->enabled);
467}
468
584560f1 469static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
ac10a927 470 const struct sr_channel_group *cg)
8ab929d6 471{
cf0280fa 472 int cg_type = CG_NONE;
e66d1892
UH
473 struct dev_context *devc;
474 const struct scope_config *model;
f3c60fb6 475
e66d1892
UH
476 devc = (sdi) ? sdi->priv : NULL;
477 model = (devc) ? devc->model_config : NULL;
f3c60fb6 478
f3c60fb6
SA
479 if (!cg) {
480 switch (key) {
e66d1892 481 case SR_CONF_SCAN_OPTIONS:
f3c60fb6 482 case SR_CONF_DEVICE_OPTIONS:
4b25cbff 483 return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
f3c60fb6
SA
484 case SR_CONF_TIMEBASE:
485 *data = build_tuples(&dlm_timebases, ARRAY_SIZE(dlm_timebases));
486 return SR_OK;
487 case SR_CONF_TRIGGER_SOURCE:
488 if (!model)
489 return SR_ERR_ARG;
490 *data = g_variant_new_strv(*model->trigger_sources,
491 g_strv_length((char **)*model->trigger_sources));
492 return SR_OK;
493 case SR_CONF_TRIGGER_SLOPE:
494 *data = g_variant_new_strv(dlm_trigger_slopes,
495 g_strv_length((char **)dlm_trigger_slopes));
496 return SR_OK;
497 case SR_CONF_NUM_HDIV:
49f49cb5 498 *data = g_variant_new_uint32(model->num_xdivs);
f3c60fb6
SA
499 return SR_OK;
500 default:
501 return SR_ERR_NA;
502 }
503 }
504
505 if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
506 return SR_ERR;
507
8ab929d6 508 switch (key) {
8ab929d6 509 case SR_CONF_DEVICE_OPTIONS:
f3c60fb6 510 if (cg_type == CG_ANALOG) {
584560f1 511 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
4b25cbff 512 analog_devopts, ARRAY_SIZE(analog_devopts), sizeof(uint32_t));
f3c60fb6
SA
513 } else if (cg_type == CG_DIGITAL) {
514 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
4b25cbff 515 digital_devopts, ARRAY_SIZE(digital_devopts), sizeof(uint32_t));
8ab929d6 516 } else {
584560f1
BV
517 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
518 NULL, 0, sizeof(uint32_t));
8ab929d6
SA
519 }
520 break;
521 case SR_CONF_COUPLING:
522 if (cg_type == CG_NONE)
523 return SR_ERR_CHANNEL_GROUP;
524 *data = g_variant_new_strv(*model->coupling_options,
ac10a927 525 g_strv_length((char **)*model->coupling_options));
8ab929d6 526 break;
8ab929d6
SA
527 case SR_CONF_VDIV:
528 if (cg_type == CG_NONE)
529 return SR_ERR_CHANNEL_GROUP;
f3c60fb6 530 *data = build_tuples(&dlm_vdivs, ARRAY_SIZE(dlm_vdivs));
8ab929d6
SA
531 break;
532 default:
533 return SR_ERR_NA;
534 }
535
536 return SR_OK;
537}
538
539static int dlm_check_channels(GSList *channels)
540{
541 GSList *l;
542 struct sr_channel *ch;
543 gboolean enabled_pod1, enabled_chan4;
544
545 enabled_pod1 = enabled_chan4 = FALSE;
546
547 /* Note: On the DLM2000, CH4 and Logic are shared. */
548 /* TODO Handle non-DLM2000 models. */
549 for (l = channels; l; l = l->next) {
550 ch = l->data;
551 switch (ch->type) {
552 case SR_CHANNEL_ANALOG:
553 if (ch->index == 3)
554 enabled_chan4 = TRUE;
555 break;
556 case SR_CHANNEL_LOGIC:
557 enabled_pod1 = TRUE;
558 break;
559 default:
560 return SR_ERR;
561 }
562 }
563
564 if (enabled_pod1 && enabled_chan4)
565 return SR_ERR;
566
567 return SR_OK;
568}
569
695dc859 570static int dev_acquisition_start(const struct sr_dev_inst *sdi)
8ab929d6
SA
571{
572 GSList *l;
573 gboolean digital_added;
574 struct sr_channel *ch;
575 struct dev_context *devc;
576 struct sr_scpi_dev_inst *scpi;
577
8ab929d6
SA
578 scpi = sdi->conn;
579 devc = sdi->priv;
580 digital_added = FALSE;
581
582 g_slist_free(devc->enabled_channels);
583 devc->enabled_channels = NULL;
584
585 for (l = sdi->channels; l; l = l->next) {
586 ch = l->data;
587 if (!ch->enabled)
588 continue;
589 /* Only add a single digital channel. */
590 if (ch->type != SR_CHANNEL_LOGIC || !digital_added) {
591 devc->enabled_channels = g_slist_append(
ac10a927
SA
592 devc->enabled_channels, ch);
593 if (ch->type == SR_CHANNEL_LOGIC)
594 digital_added = TRUE;
8ab929d6
SA
595 }
596 }
597
598 if (!devc->enabled_channels)
599 return SR_ERR;
600
601 if (dlm_check_channels(devc->enabled_channels) != SR_OK) {
602 sr_err("Invalid channel configuration specified!");
603 return SR_ERR_NA;
604 }
605
af3487ec
SA
606 /* Request data for the first enabled channel. */
607 devc->current_channel = devc->enabled_channels;
608 dlm_channel_data_request(sdi);
609
0028d5a1 610 sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 5,
8ab929d6
SA
611 dlm_data_receive, (void *)sdi);
612
613 return SR_OK;
614}
615
695dc859 616static int dev_acquisition_stop(struct sr_dev_inst *sdi)
8ab929d6
SA
617{
618 struct dev_context *devc;
8ab929d6 619
bee2b016 620 std_session_send_df_end(sdi);
8ab929d6 621
8ab929d6
SA
622 devc = sdi->priv;
623
624 devc->num_frames = 0;
625 g_slist_free(devc->enabled_channels);
626 devc->enabled_channels = NULL;
af3487ec
SA
627
628 sr_scpi_source_remove(sdi->session, sdi->conn);
8ab929d6
SA
629
630 return SR_OK;
631}
10763937 632
dd5c48a6 633static struct sr_dev_driver yokogawa_dlm_driver_info = {
10763937 634 .name = "yokogawa-dlm",
ac10a927 635 .longname = "Yokogawa DL/DLM",
10763937 636 .api_version = 1,
c2fdcc25 637 .init = std_init,
700d6b64 638 .cleanup = std_cleanup,
8ab929d6 639 .scan = scan,
c01bf34c 640 .dev_list = std_dev_list,
8ab929d6
SA
641 .dev_clear = dev_clear,
642 .config_get = config_get,
643 .config_set = config_set,
c65a021c 644 .config_channel_set = config_channel_set,
8ab929d6
SA
645 .config_list = config_list,
646 .dev_open = dev_open,
647 .dev_close = dev_close,
648 .dev_acquisition_start = dev_acquisition_start,
649 .dev_acquisition_stop = dev_acquisition_stop,
41812aca 650 .context = NULL,
10763937 651};
dd5c48a6 652SR_REGISTER_DEV_DRIVER(yokogawa_dlm_driver_info);