]> sigrok.org Git - libsigrok.git/blob - src/hardware/hameg-hmo/api.c
0abc722cda4fe9e053af0480d0d4309a814671a5
[libsigrok.git] / src / hardware / hameg-hmo / api.c
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2013 poljar (Damir Jelić) <poljarinho@gmail.com>
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 3 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, see <http://www.gnu.org/licenses/>.
18  */
19
20 #include <config.h>
21 #include <stdlib.h>
22 #include "scpi.h"
23 #include "protocol.h"
24
25 #define SERIALCOMM "115200/8n1/flow=1"
26
27 static struct sr_dev_driver hameg_hmo_driver_info;
28
29 static const char *manufacturers[] = {
30         "HAMEG",
31         "Rohde&Schwarz",
32 };
33
34 static const uint32_t scanopts[] = {
35         SR_CONF_CONN,
36         SR_CONF_SERIALCOMM,
37 };
38
39 static const uint32_t drvopts[] = {
40         SR_CONF_OSCILLOSCOPE,
41 };
42
43 enum {
44         CG_INVALID = -1,
45         CG_NONE,
46         CG_ANALOG,
47         CG_DIGITAL,
48 };
49
50 static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
51 {
52         struct sr_dev_inst *sdi;
53         struct dev_context *devc;
54         struct sr_scpi_hw_info *hw_info;
55
56         sdi = NULL;
57         devc = NULL;
58         hw_info = NULL;
59
60         if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
61                 sr_info("Couldn't get IDN response.");
62                 goto fail;
63         }
64
65         if (std_str_idx_s(hw_info->manufacturer, ARRAY_AND_SIZE(manufacturers)) < 0)
66                 goto fail;
67
68         sdi = g_malloc0(sizeof(struct sr_dev_inst));
69         sdi->vendor = g_strdup(hw_info->manufacturer);
70         sdi->model = g_strdup(hw_info->model);
71         sdi->version = g_strdup(hw_info->firmware_version);
72         sdi->serial_num = g_strdup(hw_info->serial_number);
73         sdi->driver = &hameg_hmo_driver_info;
74         sdi->inst_type = SR_INST_SCPI;
75         sdi->conn = scpi;
76
77         sr_scpi_hw_info_free(hw_info);
78         hw_info = NULL;
79
80         devc = g_malloc0(sizeof(struct dev_context));
81
82         sdi->priv = devc;
83
84         if (hmo_init_device(sdi) != SR_OK)
85                 goto fail;
86
87         return sdi;
88
89 fail:
90         sr_scpi_hw_info_free(hw_info);
91         sr_dev_inst_free(sdi);
92         g_free(devc);
93
94         return NULL;
95 }
96
97 static GSList *scan(struct sr_dev_driver *di, GSList *options)
98 {
99         return sr_scpi_scan(di->context, options, probe_device);
100 }
101
102 static void clear_helper(struct dev_context *devc)
103 {
104         hmo_scope_state_free(devc->model_state);
105         g_free(devc->analog_groups);
106         g_free(devc->digital_groups);
107 }
108
109 static int dev_clear(const struct sr_dev_driver *di)
110 {
111         return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper);
112 }
113
114 static int dev_open(struct sr_dev_inst *sdi)
115 {
116         if (sr_scpi_open(sdi->conn) != SR_OK)
117                 return SR_ERR;
118
119         if (hmo_scope_state_get(sdi) != SR_OK)
120                 return SR_ERR;
121
122         return SR_OK;
123 }
124
125 static int dev_close(struct sr_dev_inst *sdi)
126 {
127         return sr_scpi_close(sdi->conn);
128 }
129
130 static int check_channel_group(struct dev_context *devc,
131                              const struct sr_channel_group *cg)
132 {
133         const struct scope_config *model;
134
135         model = devc->model_config;
136
137         if (!cg)
138                 return CG_NONE;
139
140         if (std_cg_idx(cg, devc->analog_groups, model->analog_channels) >= 0)
141                 return CG_ANALOG;
142
143         if (std_cg_idx(cg, devc->digital_groups, model->digital_pods) >= 0)
144                 return CG_DIGITAL;
145
146         sr_err("Invalid channel group specified.");
147
148         return CG_INVALID;
149 }
150
151 static int config_get(uint32_t key, GVariant **data,
152         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
153 {
154         int cg_type, idx;
155         struct dev_context *devc;
156         const struct scope_config *model;
157         struct scope_state *state;
158
159         if (!sdi)
160                 return SR_ERR_ARG;
161
162         devc = sdi->priv;
163
164         if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
165                 return SR_ERR;
166
167         model = devc->model_config;
168         state = devc->model_state;
169
170         switch (key) {
171         case SR_CONF_NUM_HDIV:
172                 *data = g_variant_new_int32(model->num_xdivs);
173                 break;
174         case SR_CONF_TIMEBASE:
175                 *data = g_variant_new("(tt)", (*model->timebases)[state->timebase][0],
176                                       (*model->timebases)[state->timebase][1]);
177                 break;
178         case SR_CONF_NUM_VDIV:
179                 if (!cg) {
180                         return SR_ERR_CHANNEL_GROUP;
181                 } else if (cg_type == CG_ANALOG) {
182                         if (std_cg_idx(cg, devc->analog_groups, model->analog_channels) < 0)
183                                 return SR_ERR_ARG;
184                         *data = g_variant_new_int32(model->num_ydivs);
185                 } else {
186                         return SR_ERR_NA;
187                 }
188                 break;
189         case SR_CONF_VDIV:
190                 if (!cg) {
191                         return SR_ERR_CHANNEL_GROUP;
192                 } else if (cg_type == CG_ANALOG) {
193                         if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
194                                 return SR_ERR_ARG;
195                         *data = g_variant_new("(tt)",
196                                               (*model->vdivs)[state->analog_channels[idx].vdiv][0],
197                                               (*model->vdivs)[state->analog_channels[idx].vdiv][1]);
198                 } else {
199                         return SR_ERR_NA;
200                 }
201                 break;
202         case SR_CONF_TRIGGER_SOURCE:
203                 *data = g_variant_new_string((*model->trigger_sources)[state->trigger_source]);
204                 break;
205         case SR_CONF_TRIGGER_SLOPE:
206                 *data = g_variant_new_string((*model->trigger_slopes)[state->trigger_slope]);
207                 break;
208         case SR_CONF_HORIZ_TRIGGERPOS:
209                 *data = g_variant_new_double(state->horiz_triggerpos);
210                 break;
211         case SR_CONF_COUPLING:
212                 if (!cg) {
213                         return SR_ERR_CHANNEL_GROUP;
214                 } else if (cg_type == CG_ANALOG) {
215                         if ((idx = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
216                                 return SR_ERR_ARG;
217                         *data = g_variant_new_string((*model->coupling_options)[state->analog_channels[idx].coupling]);
218                 } else {
219                         return SR_ERR_NA;
220                 }
221                 break;
222         case SR_CONF_SAMPLERATE:
223                 *data = g_variant_new_uint64(state->sample_rate);
224                 break;
225         default:
226                 return SR_ERR_NA;
227         }
228
229         return SR_OK;
230 }
231
232 static int config_set(uint32_t key, GVariant *data,
233         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
234 {
235         int ret, cg_type, idx, j;
236         char command[MAX_COMMAND_SIZE], float_str[30];
237         struct dev_context *devc;
238         const struct scope_config *model;
239         struct scope_state *state;
240         double tmp_d;
241         gboolean update_sample_rate;
242
243         if (!sdi)
244                 return SR_ERR_ARG;
245
246         devc = sdi->priv;
247
248         if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
249                 return SR_ERR;
250
251         model = devc->model_config;
252         state = devc->model_state;
253         update_sample_rate = FALSE;
254
255         ret = SR_ERR_NA;
256
257         switch (key) {
258         case SR_CONF_LIMIT_FRAMES:
259                 devc->frame_limit = g_variant_get_uint64(data);
260                 ret = SR_OK;
261                 break;
262         case SR_CONF_TRIGGER_SOURCE:
263                 if ((idx = std_str_idx(data, *model->trigger_sources, model->num_trigger_sources)) < 0)
264                         return SR_ERR_ARG;
265                 state->trigger_source = idx;
266                 g_snprintf(command, sizeof(command),
267                            (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SOURCE],
268                            (*model->trigger_sources)[idx]);
269                 ret = sr_scpi_send(sdi->conn, command);
270                 break;
271         case SR_CONF_VDIV:
272                 if (!cg)
273                         return SR_ERR_CHANNEL_GROUP;
274                 if ((idx = std_u64_tuple_idx(data, *model->vdivs, model->num_vdivs)) < 0)
275                         return SR_ERR_ARG;
276                 if ((j = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
277                         return SR_ERR_ARG;
278                 state->analog_channels[j].vdiv = idx;
279                 g_ascii_formatd(float_str, sizeof(float_str), "%E",
280                         (float) (*model->vdivs)[idx][0] / (*model->vdivs)[idx][1]);
281                 g_snprintf(command, sizeof(command),
282                            (*model->scpi_dialect)[SCPI_CMD_SET_VERTICAL_DIV],
283                            j + 1, float_str);
284                 if (sr_scpi_send(sdi->conn, command) != SR_OK ||
285                     sr_scpi_get_opc(sdi->conn) != SR_OK)
286                         return SR_ERR;
287                 ret = SR_OK;
288                 break;
289         case SR_CONF_TIMEBASE:
290                 if ((idx = std_u64_tuple_idx(data, *model->timebases, model->num_timebases)) < 0)
291                         return SR_ERR_ARG;
292                 state->timebase = idx;
293                 g_ascii_formatd(float_str, sizeof(float_str), "%E",
294                         (float) (*model->timebases)[idx][0] / (*model->timebases)[idx][1]);
295                 g_snprintf(command, sizeof(command),
296                            (*model->scpi_dialect)[SCPI_CMD_SET_TIMEBASE],
297                            float_str);
298                 ret = sr_scpi_send(sdi->conn, command);
299                 update_sample_rate = TRUE;
300                 break;
301         case SR_CONF_HORIZ_TRIGGERPOS:
302                 tmp_d = g_variant_get_double(data);
303                 if (tmp_d < 0.0 || tmp_d > 1.0)
304                         return SR_ERR;
305                 state->horiz_triggerpos = tmp_d;
306                 tmp_d = -(tmp_d - 0.5) *
307                         ((double) (*model->timebases)[state->timebase][0] /
308                         (*model->timebases)[state->timebase][1])
309                          * model->num_xdivs;
310                 g_ascii_formatd(float_str, sizeof(float_str), "%E", tmp_d);
311                 g_snprintf(command, sizeof(command),
312                            (*model->scpi_dialect)[SCPI_CMD_SET_HORIZ_TRIGGERPOS],
313                            float_str);
314                 ret = sr_scpi_send(sdi->conn, command);
315                 break;
316         case SR_CONF_TRIGGER_SLOPE:
317                 if ((idx = std_str_idx(data, *model->trigger_slopes, model->num_trigger_slopes)) < 0)
318                         return SR_ERR_ARG;
319                 state->trigger_slope = idx;
320                 g_snprintf(command, sizeof(command),
321                            (*model->scpi_dialect)[SCPI_CMD_SET_TRIGGER_SLOPE],
322                            (*model->trigger_slopes)[idx]);
323                 ret = sr_scpi_send(sdi->conn, command);
324                 break;
325         case SR_CONF_COUPLING:
326                 if (!cg)
327                         return SR_ERR_CHANNEL_GROUP;
328                 if ((idx = std_str_idx(data, *model->coupling_options, model->num_coupling_options)) < 0)
329                         return SR_ERR_ARG;
330                 if ((j = std_cg_idx(cg, devc->analog_groups, model->analog_channels)) < 0)
331                         return SR_ERR_ARG;
332                 state->analog_channels[j].coupling = idx;
333                 g_snprintf(command, sizeof(command),
334                            (*model->scpi_dialect)[SCPI_CMD_SET_COUPLING],
335                            j + 1, (*model->coupling_options)[idx]);
336                 if (sr_scpi_send(sdi->conn, command) != SR_OK ||
337                     sr_scpi_get_opc(sdi->conn) != SR_OK)
338                         return SR_ERR;
339                 ret = SR_OK;
340                 break;
341         default:
342                 ret = SR_ERR_NA;
343                 break;
344         }
345
346         if (ret == SR_OK)
347                 ret = sr_scpi_get_opc(sdi->conn);
348
349         if (ret == SR_OK && update_sample_rate)
350                 ret = hmo_update_sample_rate(sdi);
351
352         return ret;
353 }
354
355 static int config_list(uint32_t key, GVariant **data,
356         const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
357 {
358         int cg_type = CG_NONE;
359         struct dev_context *devc = NULL;
360         const struct scope_config *model = NULL;
361
362         if (sdi) {
363                 devc = sdi->priv;
364                 if ((cg_type = check_channel_group(devc, cg)) == CG_INVALID)
365                         return SR_ERR;
366
367                 model = devc->model_config;
368         }
369
370         switch (key) {
371         case SR_CONF_SCAN_OPTIONS:
372                 *data = std_gvar_array_u32(ARRAY_AND_SIZE(scanopts));
373                 break;
374         case SR_CONF_DEVICE_OPTIONS:
375                 if (!cg) {
376                         if (model)
377                                 *data = std_gvar_array_u32((const uint32_t *)model->devopts, model->num_devopts);
378                         else
379                                 *data = std_gvar_array_u32(ARRAY_AND_SIZE(drvopts));
380                 } else if (cg_type == CG_ANALOG) {
381                         *data = std_gvar_array_u32((const uint32_t *)model->devopts_cg_analog, model->num_devopts_cg_analog);
382                 } else {
383                         *data = std_gvar_array_u32(NULL, 0);
384                 }
385                 break;
386         case SR_CONF_COUPLING:
387                 if (!cg)
388                         return SR_ERR_CHANNEL_GROUP;
389                 *data = g_variant_new_strv(*model->coupling_options, model->num_coupling_options);
390                 break;
391         case SR_CONF_TRIGGER_SOURCE:
392                 if (!model)
393                         return SR_ERR_ARG;
394                 *data = g_variant_new_strv(*model->trigger_sources, model->num_trigger_sources);
395                 break;
396         case SR_CONF_TRIGGER_SLOPE:
397                 if (!model)
398                         return SR_ERR_ARG;
399                 *data = g_variant_new_strv(*model->trigger_slopes, model->num_trigger_slopes);
400                 break;
401         case SR_CONF_TIMEBASE:
402                 if (!model)
403                         return SR_ERR_ARG;
404                 *data = std_gvar_tuple_array(*model->timebases, model->num_timebases);
405                 break;
406         case SR_CONF_VDIV:
407                 if (!cg)
408                         return SR_ERR_CHANNEL_GROUP;
409                 *data = std_gvar_tuple_array(*model->vdivs, model->num_vdivs);
410                 break;
411         default:
412                 return SR_ERR_NA;
413         }
414
415         return SR_OK;
416 }
417
418 SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi)
419 {
420         char command[MAX_COMMAND_SIZE];
421         struct sr_channel *ch;
422         struct dev_context *devc;
423         const struct scope_config *model;
424
425         devc = sdi->priv;
426         model = devc->model_config;
427
428         ch = devc->current_channel->data;
429
430         switch (ch->type) {
431         case SR_CHANNEL_ANALOG:
432                 g_snprintf(command, sizeof(command),
433                            (*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA],
434 #ifdef WORDS_BIGENDIAN
435                            "MSBF",
436 #else
437                            "LSBF",
438 #endif
439                            ch->index + 1);
440                 break;
441         case SR_CHANNEL_LOGIC:
442                 g_snprintf(command, sizeof(command),
443                            (*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA],
444                            ch->index < 8 ? 1 : 2);
445                 break;
446         default:
447                 sr_err("Invalid channel type.");
448                 break;
449         }
450
451         return sr_scpi_send(sdi->conn, command);
452 }
453
454 static int hmo_check_channels(GSList *channels)
455 {
456         GSList *l;
457         struct sr_channel *ch;
458         gboolean enabled_chan[MAX_ANALOG_CHANNEL_COUNT];
459         gboolean enabled_pod[MAX_DIGITAL_GROUP_COUNT];
460         size_t idx;
461
462         /* Preset "not enabled" for all channels / pods. */
463         for (idx = 0; idx < ARRAY_SIZE(enabled_chan); idx++)
464                 enabled_chan[idx] = FALSE;
465         for (idx = 0; idx < ARRAY_SIZE(enabled_pod); idx++)
466                 enabled_pod[idx] = FALSE;
467
468         /*
469          * Determine which channels / pods are required for the caller's
470          * specified configuration.
471          */
472         for (l = channels; l; l = l->next) {
473                 ch = l->data;
474                 switch (ch->type) {
475                 case SR_CHANNEL_ANALOG:
476                         idx = ch->index;
477                         if (idx < ARRAY_SIZE(enabled_chan))
478                                 enabled_chan[idx] = TRUE;
479                         break;
480                 case SR_CHANNEL_LOGIC:
481                         idx = ch->index / 8;
482                         if (idx < ARRAY_SIZE(enabled_pod))
483                                 enabled_pod[idx] = TRUE;
484                         break;
485                 default:
486                         return SR_ERR;
487                 }
488         }
489
490         /*
491          * Check for resource conflicts. Some channels can be either
492          * analog or digital, but never both at the same time.
493          *
494          * Note that the constraints might depend on the specific model.
495          * These tests might need some adjustment when support for more
496          * models gets added to the driver.
497          */
498         if (enabled_pod[0] && enabled_chan[2])
499                 return SR_ERR;
500         if (enabled_pod[1] && enabled_chan[3])
501                 return SR_ERR;
502         return SR_OK;
503 }
504
505 static int hmo_setup_channels(const struct sr_dev_inst *sdi)
506 {
507         GSList *l;
508         unsigned int i;
509         gboolean *pod_enabled, setup_changed;
510         char command[MAX_COMMAND_SIZE];
511         struct scope_state *state;
512         const struct scope_config *model;
513         struct sr_channel *ch;
514         struct dev_context *devc;
515         struct sr_scpi_dev_inst *scpi;
516
517         devc = sdi->priv;
518         scpi = sdi->conn;
519         state = devc->model_state;
520         model = devc->model_config;
521         setup_changed = FALSE;
522
523         pod_enabled = g_try_malloc0(sizeof(gboolean) * model->digital_pods);
524
525         for (l = sdi->channels; l; l = l->next) {
526                 ch = l->data;
527                 switch (ch->type) {
528                 case SR_CHANNEL_ANALOG:
529                         if (ch->enabled == state->analog_channels[ch->index].state)
530                                 break;
531                         g_snprintf(command, sizeof(command),
532                                    (*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE],
533                                    ch->index + 1, ch->enabled);
534
535                         if (sr_scpi_send(scpi, command) != SR_OK)
536                                 return SR_ERR;
537                         state->analog_channels[ch->index].state = ch->enabled;
538                         setup_changed = TRUE;
539                         break;
540                 case SR_CHANNEL_LOGIC:
541                         /*
542                          * A digital POD needs to be enabled for every group of
543                          * 8 channels.
544                          */
545                         if (ch->enabled)
546                                 pod_enabled[ch->index < 8 ? 0 : 1] = TRUE;
547
548                         if (ch->enabled == state->digital_channels[ch->index])
549                                 break;
550                         g_snprintf(command, sizeof(command),
551                                    (*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE],
552                                    ch->index, ch->enabled);
553
554                         if (sr_scpi_send(scpi, command) != SR_OK)
555                                 return SR_ERR;
556
557                         state->digital_channels[ch->index] = ch->enabled;
558                         setup_changed = TRUE;
559                         break;
560                 default:
561                         return SR_ERR;
562                 }
563         }
564
565         for (i = 0; i < model->digital_pods; i++) {
566                 if (state->digital_pods[i] == pod_enabled[i])
567                         continue;
568                 g_snprintf(command, sizeof(command),
569                            (*model->scpi_dialect)[SCPI_CMD_SET_DIG_POD_STATE],
570                            i + 1, pod_enabled[i]);
571                 if (sr_scpi_send(scpi, command) != SR_OK)
572                         return SR_ERR;
573                 state->digital_pods[i] = pod_enabled[i];
574                 setup_changed = TRUE;
575         }
576
577         g_free(pod_enabled);
578
579         if (setup_changed && hmo_update_sample_rate(sdi) != SR_OK)
580                 return SR_ERR;
581
582         return SR_OK;
583 }
584
585 static int dev_acquisition_start(const struct sr_dev_inst *sdi)
586 {
587         GSList *l;
588         gboolean digital_added[MAX_DIGITAL_GROUP_COUNT];
589         size_t group, pod_count;
590         struct sr_channel *ch;
591         struct dev_context *devc;
592         struct sr_scpi_dev_inst *scpi;
593         int ret;
594
595         scpi = sdi->conn;
596         devc = sdi->priv;
597
598         /* Preset empty results. */
599         for (group = 0; group < ARRAY_SIZE(digital_added); group++)
600                 digital_added[group] = FALSE;
601         g_slist_free(devc->enabled_channels);
602         devc->enabled_channels = NULL;
603
604         /*
605          * Contruct the list of enabled channels. Determine the highest
606          * number of digital pods involved in the acquisition.
607          */
608         pod_count = 0;
609         for (l = sdi->channels; l; l = l->next) {
610                 ch = l->data;
611                 if (!ch->enabled)
612                         continue;
613                 /* Only add a single digital channel per group (pod). */
614                 group = ch->index / 8;
615                 if (ch->type != SR_CHANNEL_LOGIC || !digital_added[group]) {
616                         devc->enabled_channels = g_slist_append(
617                                         devc->enabled_channels, ch);
618                         if (ch->type == SR_CHANNEL_LOGIC) {
619                                 digital_added[group] = TRUE;
620                                 if (pod_count < group + 1)
621                                         pod_count = group + 1;
622                         }
623                 }
624         }
625         if (!devc->enabled_channels)
626                 return SR_ERR;
627         devc->pod_count = pod_count;
628         devc->logic_data = NULL;
629
630         /*
631          * Check constraints. Some channels can be either analog or
632          * digital, but not both at the same time.
633          */
634         if (hmo_check_channels(devc->enabled_channels) != SR_OK) {
635                 sr_err("Invalid channel configuration specified!");
636                 ret = SR_ERR_NA;
637                 goto free_enabled;
638         }
639
640         /*
641          * Configure the analog and digital channels and the
642          * corresponding digital pods.
643          */
644         if (hmo_setup_channels(sdi) != SR_OK) {
645                 sr_err("Failed to setup channel configuration!");
646                 ret = SR_ERR;
647                 goto free_enabled;
648         }
649
650         /*
651          * Start acquisition on the first enabled channel. The
652          * receive routine will continue driving the acquisition.
653          */
654         sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50,
655                         hmo_receive_data, (void *)sdi);
656
657         std_session_send_df_header(sdi);
658
659         devc->current_channel = devc->enabled_channels;
660
661         return hmo_request_data(sdi);
662
663 free_enabled:
664         g_slist_free(devc->enabled_channels);
665         devc->enabled_channels = NULL;
666         return ret;
667 }
668
669 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
670 {
671         struct dev_context *devc;
672         struct sr_scpi_dev_inst *scpi;
673
674         std_session_send_df_end(sdi);
675
676         devc = sdi->priv;
677
678         devc->num_frames = 0;
679         g_slist_free(devc->enabled_channels);
680         devc->enabled_channels = NULL;
681         scpi = sdi->conn;
682         sr_scpi_source_remove(sdi->session, scpi);
683
684         return SR_OK;
685 }
686
687 static struct sr_dev_driver hameg_hmo_driver_info = {
688         .name = "hameg-hmo",
689         .longname = "Hameg HMO",
690         .api_version = 1,
691         .init = std_init,
692         .cleanup = std_cleanup,
693         .scan = scan,
694         .dev_list = std_dev_list,
695         .dev_clear = dev_clear,
696         .config_get = config_get,
697         .config_set = config_set,
698         .config_list = config_list,
699         .dev_open = dev_open,
700         .dev_close = dev_close,
701         .dev_acquisition_start = dev_acquisition_start,
702         .dev_acquisition_stop = dev_acquisition_stop,
703         .context = NULL,
704 };
705 SR_REGISTER_DEV_DRIVER(hameg_hmo_driver_info);