2 * This file is part of the libsigrok project.
4 * Copyright (C) 2014 abraxa (Soeren Apel) <soeren@apelpie.net>
5 * Based on the Hameg HMO driver by poljar (Damir Jelić) <poljarinho@gmail.com>
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.
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.
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/>.
24 * <em>Yokogawa DL/DLM series</em> oscilloscope driver
32 static const char *dlm_coupling_options[] = {
40 static const char *dlm_2ch_trigger_sources[] = {
48 /* TODO: Is BITx handled correctly or is Dx required? */
49 static const char *dlm_4ch_trigger_sources[] = {
67 /* Note: Values must correlate to the trigger_slopes values. */
68 const char *dlm_trigger_slopes[3] = {
74 const uint64_t dlm_timebases[36][2] = {
117 const uint64_t dlm_vdivs[17][2] = {
139 static const char *scope_analog_channel_names[] = {
146 static const char *scope_digital_channel_names_8[] = {
157 static const char *scope_digital_channel_names_32[] = {
192 static const struct scope_config scope_models[] = {
194 .model_id = {"710105", "710115", "710125", NULL},
195 .model_name = {"DLM2022", "DLM2032", "DLM2052", NULL},
196 .analog_channels = 2,
197 .digital_channels = 0,
200 .analog_names = &scope_analog_channel_names,
201 .digital_names = &scope_digital_channel_names_8,
203 .coupling_options = &dlm_coupling_options,
204 .trigger_sources = &dlm_2ch_trigger_sources,
210 .model_id = {"710110", "710120", "710130", NULL},
211 .model_name = {"DLM2024", "DLM2034", "DLM2054", NULL},
212 .analog_channels = 4,
213 .digital_channels = 8,
216 .analog_names = &scope_analog_channel_names,
217 .digital_names = &scope_digital_channel_names_8,
219 .coupling_options = &dlm_coupling_options,
220 .trigger_sources = &dlm_4ch_trigger_sources,
226 .model_id = {"701307", "701308", "701310", "701311",
227 "701312", "701313", NULL},
228 .model_name = {"DL9040", "DL9040L", "DL9140", "DL9140L",
229 "DL9240", "DL9240L", NULL},
230 .analog_channels = 4,
231 .digital_channels = 0,
234 .analog_names = &scope_analog_channel_names,
235 .digital_names = NULL,
237 .coupling_options = &dlm_coupling_options,
238 .trigger_sources = &dlm_4ch_trigger_sources,
244 .model_id = {"701320", "701321", NULL},
245 .model_name = {"DL9505L", "DL9510L", NULL},
246 .analog_channels = 4,
247 .digital_channels = 16,
250 .analog_names = &scope_analog_channel_names,
251 .digital_names = &scope_digital_channel_names_32,
253 .coupling_options = &dlm_coupling_options,
254 .trigger_sources = &dlm_4ch_trigger_sources,
260 .model_id = {"701330", "701331", NULL},
261 .model_name = {"DL9705L", "DL9710L", NULL},
262 .analog_channels = 4,
263 .digital_channels = 32,
266 .analog_names = &scope_analog_channel_names,
267 .digital_names = &scope_digital_channel_names_32,
269 .coupling_options = &dlm_coupling_options,
270 .trigger_sources = &dlm_4ch_trigger_sources,
278 * Prints out the state of the device as we currently know it.
280 * @param config This is the scope configuration.
281 * @param state The current scope state to print.
283 static void scope_state_dump(const struct scope_config *config,
284 struct scope_state *state)
289 for (i = 0; i < config->analog_channels; i++) {
290 tmp = sr_voltage_string(dlm_vdivs[state->analog_states[i].vdiv][0],
291 dlm_vdivs[state->analog_states[i].vdiv][1]);
292 sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)",
293 i + 1, state->analog_states[i].state ? "On" : "Off",
294 (*config->coupling_options)[state->analog_states[i].coupling],
295 tmp, state->analog_states[i].vertical_offset);
298 for (i = 0; i < config->digital_channels; i++) {
299 sr_info("State of digital channel %d -> %s", i,
300 state->digital_states[i] ? "On" : "Off");
303 for (i = 0; i < config->pods; i++) {
304 sr_info("State of digital POD %d -> %s", i,
305 state->pod_states[i] ? "On" : "Off");
308 tmp = sr_period_string(dlm_timebases[state->timebase][0] *
309 dlm_timebases[state->timebase][1]);
310 sr_info("Current timebase: %s", tmp);
313 tmp = sr_samplerate_string(state->sample_rate);
314 sr_info("Current samplerate: %s", tmp);
317 sr_info("Current samples per acquisition (i.e. frame): %d",
318 state->samples_per_frame);
320 sr_info("Current trigger: %s (source), %s (slope) %.2f (offset)",
321 (*config->trigger_sources)[state->trigger_source],
322 dlm_trigger_slopes[state->trigger_slope],
323 state->horiz_triggerpos);
327 * Searches through an array of strings and returns the index to the
328 * array where a given string is located.
330 * @param value The string to search for.
331 * @param array The array of strings.
332 * @param result The index at which value is located in array. -1 on error.
334 * @return SR_ERR when value couldn't be found, SR_OK otherwise.
336 static int array_option_get(char *value, const char *(*array)[],
343 for (i = 0; (*array)[i]; i++)
344 if (!g_strcmp0(value, (*array)[i])) {
356 * This function takes a value of the form "2.000E-03", converts it to a
357 * significand / factor pair and returns the index of an array where
358 * a matching pair was found.
360 * It's a bit convoluted because of floating-point issues. The value "10.00E-09"
361 * is parsed by g_ascii_strtod() as 0.000000009999999939, for example.
362 * Therefore it's easier to break the number up into two strings and handle
365 * @param value The string to be parsed.
366 * @param array The array of s/f pairs.
367 * @param array_len The number of pairs in the array.
368 * @param result The index at which a matching pair was found.
370 * @return SR_ERR on any parsing error, SR_OK otherwise.
372 static int array_float_get(gchar *value, const uint64_t array[][2],
373 int array_len, int *result)
379 gchar ss[10], es[10];
381 memset(ss, 0, sizeof(ss));
382 memset(es, 0, sizeof(es));
384 strncpy(ss, value, 5);
385 strncpy(es, &(value[6]), 3);
387 if (sr_atof_ascii(ss, &s) != SR_OK)
389 if (sr_atoi(es, &i) != SR_OK)
392 /* Transform e.g. 10^-03 to 1000 as the array stores the inverse. */
396 * Adjust the significand/factor pair to make sure
397 * that f is a multiple of 1000.
399 while ((int)fmod(log10(f), 3) > 0) { s *= 10; f *= 10; }
401 /* Truncate s to circumvent rounding errors. */
402 s_int = (unsigned int)s;
404 for (i = 0; i < array_len; i++) {
405 if ( (s_int == array[i][0]) && (f == array[i][1]) ) {
415 * Obtains information about all analog channels from the oscilloscope.
416 * The internal state information is updated accordingly.
418 * @param sdi The device instance.
419 * @param config The device's device configuration.
420 * @param state The device's state information.
422 * @return SR_ERR on error, SR_OK otherwise.
424 static int analog_channel_state_get(const struct sr_dev_inst *sdi,
425 const struct scope_config *config,
426 struct scope_state *state)
428 struct sr_scpi_dev_inst *scpi;
431 struct sr_channel *ch;
436 for (i = 0; i < config->analog_channels; i++) {
438 if (dlm_analog_chan_state_get(scpi, i + 1,
439 &state->analog_states[i].state) != SR_OK)
442 for (l = sdi->channels; l; l = l->next) {
444 if (ch->index == i) {
445 ch->enabled = state->analog_states[i].state;
450 if (dlm_analog_chan_vdiv_get(scpi, i + 1, &response) != SR_OK)
453 if (array_float_get(response, dlm_vdivs, ARRAY_SIZE(dlm_vdivs),
460 state->analog_states[i].vdiv = j;
462 if (dlm_analog_chan_voffs_get(scpi, i + 1,
463 &state->analog_states[i].vertical_offset) != SR_OK)
466 if (dlm_analog_chan_wrange_get(scpi, i + 1,
467 &state->analog_states[i].waveform_range) != SR_OK)
470 if (dlm_analog_chan_woffs_get(scpi, i + 1,
471 &state->analog_states[i].waveform_offset) != SR_OK)
474 if (dlm_analog_chan_coupl_get(scpi, i + 1, &response) != SR_OK) {
479 if (array_option_get(response, config->coupling_options,
480 &state->analog_states[i].coupling) != SR_OK) {
491 * Obtains information about all digital channels from the oscilloscope.
492 * The internal state information is updated accordingly.
494 * @param sdi The device instance.
495 * @param config The device's device configuration.
496 * @param state The device's state information.
498 * @return SR_ERR on error, SR_OK otherwise.
500 static int digital_channel_state_get(const struct sr_dev_inst *sdi,
501 const struct scope_config *config,
502 struct scope_state *state)
504 struct sr_scpi_dev_inst *scpi;
507 struct sr_channel *ch;
511 if (!config->digital_channels) {
512 sr_warn("Tried obtaining digital channel states on a " \
513 "model without digital inputs.");
517 for (i = 0; i < config->digital_channels; i++) {
518 if (dlm_digital_chan_state_get(scpi, i + 1,
519 &state->digital_states[i]) != SR_OK) {
523 for (l = sdi->channels; l; l = l->next) {
525 if (ch->index == i + DLM_DIG_CHAN_INDEX_OFFS) {
526 ch->enabled = state->digital_states[i];
533 sr_warn("Tried obtaining pod states on a model without pods.");
537 for (i = 0; i < config->pods; i++) {
538 if (dlm_digital_pod_state_get(scpi, i + 'A',
539 &state->pod_states[i]) != SR_OK)
546 SR_PRIV int dlm_channel_state_set(const struct sr_dev_inst *sdi,
547 const int ch_index, gboolean ch_state)
550 struct sr_channel *ch;
551 struct dev_context *devc = NULL;
552 struct scope_state *state;
553 const struct scope_config *model = NULL;
554 struct sr_scpi_dev_inst *scpi;
556 gboolean *pod_enabled;
563 state = devc->model_state;
564 model = devc->model_config;
567 pod_enabled = g_malloc0(sizeof(gboolean) * model->pods);
569 for (l = sdi->channels; l; l = l->next) {
573 case SR_CHANNEL_ANALOG:
574 if (ch->index == ch_index) {
575 if (dlm_analog_chan_state_set(scpi, ch->index + 1, ch_state) != SR_OK) {
580 ch->enabled = ch_state;
581 state->analog_states[ch->index].state = ch_state;
586 case SR_CHANNEL_LOGIC:
587 i = ch->index - DLM_DIG_CHAN_INDEX_OFFS;
589 if (ch->index == ch_index) {
590 if (dlm_digital_chan_state_set(scpi, i + 1, ch_state) != SR_OK) {
595 ch->enabled = ch_state;
596 state->digital_states[i] = ch_state;
599 /* The corresponding pod has to be enabled also. */
600 pod_enabled[i / 8] |= ch->enabled;
602 /* Also check all other channels. Maybe we can disable a pod. */
603 pod_enabled[i / 8] |= ch->enabled;
611 for (i = 0; i < model->pods; i++) {
612 if (state->pod_states[i] == pod_enabled[i])
615 if (dlm_digital_pod_state_set(scpi, i + 1, pod_enabled[i]) != SR_OK) {
620 state->pod_states[i] = pod_enabled[i];
625 if ((result == SR_OK) && !chan_found)
632 * Obtains information about the sample rate from the oscilloscope.
633 * The internal state information is updated accordingly.
635 * @param sdi The device instance.
637 * @return SR_ERR on error, SR_OK otherwise.
639 SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi)
641 struct dev_context *devc;
642 struct scope_state *state;
646 state = devc->model_state;
649 * No need to find an active channel to query the sample rate:
650 * querying any channel will do, so we use channel 1 all the time.
652 if (dlm_analog_chan_srate_get(sdi->conn, 1, &tmp_float) != SR_OK)
655 state->sample_rate = tmp_float;
661 * Obtains information about the current device state from the oscilloscope,
662 * including all analog and digital channel configurations.
663 * The internal state information is updated accordingly.
665 * @param sdi The device instance.
667 * @return SR_ERR on error, SR_OK otherwise.
669 SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi)
671 struct dev_context *devc;
672 struct scope_state *state;
673 const struct scope_config *config;
679 config = devc->model_config;
680 state = devc->model_state;
682 if (analog_channel_state_get(sdi, config, state) != SR_OK)
685 if (digital_channel_state_get(sdi, config, state) != SR_OK)
688 if (dlm_timebase_get(sdi->conn, &response) != SR_OK)
691 if (array_float_get(response, dlm_timebases,
692 ARRAY_SIZE(dlm_timebases), &i) != SR_OK) {
700 if (dlm_horiz_trigger_pos_get(sdi->conn, &tmp_float) != SR_OK)
703 /* TODO: Check if the calculation makes sense for the DLM. */
704 state->horiz_triggerpos = tmp_float /
705 (((double)dlm_timebases[state->timebase][0] /
706 dlm_timebases[state->timebase][1]) * config->num_xdivs);
707 state->horiz_triggerpos -= 0.5;
708 state->horiz_triggerpos *= -1;
710 if (dlm_trigger_source_get(sdi->conn, &response) != SR_OK) {
715 if (array_option_get(response, config->trigger_sources,
716 &state->trigger_source) != SR_OK) {
723 if (dlm_trigger_slope_get(sdi->conn, &i) != SR_OK)
726 state->trigger_slope = i;
728 if (dlm_acq_length_get(sdi->conn, &state->samples_per_frame) != SR_OK) {
729 sr_err("Failed to query acquisition length.");
733 dlm_sample_rate_query(sdi);
735 scope_state_dump(config, state);
741 * Creates a new device state structure.
743 * @param config The device configuration to use.
745 * @return The newly allocated scope_state struct.
747 static struct scope_state *dlm_scope_state_new(const struct scope_config *config)
749 struct scope_state *state;
751 state = g_malloc0(sizeof(struct scope_state));
753 state->analog_states = g_malloc0(config->analog_channels *
754 sizeof(struct analog_channel_state));
756 state->digital_states = g_malloc0(config->digital_channels *
759 state->pod_states = g_malloc0(config->pods * sizeof(gboolean));
765 * Frees the memory that was allocated by a call to dlm_scope_state_new().
767 * @param state The device state structure whose memory is to be freed.
769 SR_PRIV void dlm_scope_state_destroy(struct scope_state *state)
771 g_free(state->analog_states);
772 g_free(state->digital_states);
773 g_free(state->pod_states);
777 SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index)
784 for (i = 0; i < ARRAY_SIZE(scope_models); i++) {
785 for (j = 0; scope_models[i].model_id[j]; j++) {
786 if (!strcmp(model_id, scope_models[i].model_id[j])) {
788 *model_name = (char *)scope_models[i].model_name[j];
792 if (*model_index != -1)
796 if (*model_index == -1) {
797 sr_err("Found unsupported DLM device with model identifier %s.",
806 * Attempts to initialize a DL/DLM device and prepares internal structures
807 * if a suitable device was found.
809 * @param sdi The device instance.
811 SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
815 struct sr_channel *ch;
816 struct dev_context *devc;
820 devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
821 scope_models[model_index].analog_channels);
823 devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
824 scope_models[model_index].pods);
826 /* Add analog channels, each in its own group. */
827 for (i = 0; i < scope_models[model_index].analog_channels; i++) {
828 ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
829 (*scope_models[model_index].analog_names)[i]);
831 devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
833 devc->analog_groups[i]->name = g_strdup(
834 (char *)(*scope_models[model_index].analog_names)[i]);
835 devc->analog_groups[i]->channels = g_slist_append(NULL, ch);
837 sdi->channel_groups = g_slist_append(sdi->channel_groups,
838 devc->analog_groups[i]);
841 /* Add digital channel groups. */
842 for (i = 0; i < scope_models[model_index].pods; i++) {
843 g_snprintf(tmp, sizeof(tmp), "POD%d", i);
845 devc->digital_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
846 if (!devc->digital_groups[i])
847 return SR_ERR_MALLOC;
849 devc->digital_groups[i]->name = g_strdup(tmp);
850 sdi->channel_groups = g_slist_append(sdi->channel_groups,
851 devc->digital_groups[i]);
854 /* Add digital channels. */
855 for (i = 0; i < scope_models[model_index].digital_channels; i++) {
856 ch = sr_channel_new(sdi, DLM_DIG_CHAN_INDEX_OFFS + i,
857 SR_CHANNEL_LOGIC, TRUE,
858 (*scope_models[model_index].digital_names)[i]);
860 devc->digital_groups[i / 8]->channels = g_slist_append(
861 devc->digital_groups[i / 8]->channels, ch);
863 devc->model_config = &scope_models[model_index];
864 devc->frame_limit = 0;
866 if (!(devc->model_state = dlm_scope_state_new(devc->model_config)))
867 return SR_ERR_MALLOC;
869 /* Disable non-standard response behavior. */
870 if (dlm_response_headers_set(sdi->conn, FALSE) != SR_OK)
876 SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi)
878 struct dev_context *devc;
879 struct sr_channel *ch;
883 ch = devc->current_channel->data;
886 case SR_CHANNEL_ANALOG:
887 result = dlm_analog_data_get(sdi->conn, ch->index + 1);
889 case SR_CHANNEL_LOGIC:
890 result = dlm_digital_data_get(sdi->conn);
893 sr_err("Invalid channel type encountered (%d).",
899 devc->data_pending = TRUE;
901 devc->data_pending = FALSE;
907 * Reads and removes the block data header from a given data input.
908 * Format is #ndddd... with n being the number of decimal digits d.
909 * The string dddd... contains the decimal-encoded length of the data.
910 * Example: #9000000013 would yield a length of 13 bytes.
912 * @param data The input data.
913 * @param len The determined input data length.
915 static int dlm_block_data_header_process(GArray *data, int *len)
920 if (g_array_index(data, gchar, 0) != '#')
923 n = (uint8_t)(g_array_index(data, gchar, 1) - '0');
925 for (i = 0; i < n; i++)
926 s[i] = g_array_index(data, gchar, 2 + i);
929 if (sr_atoi(s, len) != SR_OK)
932 g_array_remove_range(data, 0, 2 + n);
938 * Turns raw sample data into voltages and sends them off to the session bus.
940 * @param data The raw sample data.
941 * @ch_state Pointer to the state of the channel whose data we're processing.
942 * @sdi The device instance.
944 * @return SR_ERR when data is trucated, SR_OK otherwise.
946 static int dlm_analog_samples_send(GArray *data,
947 struct analog_channel_state *ch_state,
948 struct sr_dev_inst *sdi)
951 float voltage, range, offset;
953 struct dev_context *devc;
954 struct scope_state *model_state;
955 struct sr_channel *ch;
956 struct sr_datafeed_analog_old analog;
957 struct sr_datafeed_packet packet;
960 model_state = devc->model_state;
961 samples = model_state->samples_per_frame;
962 ch = devc->current_channel->data;
964 if (data->len < samples * sizeof(uint8_t)) {
965 sr_err("Truncated waveform data packet received.");
969 range = ch_state->waveform_range;
970 offset = ch_state->waveform_offset;
973 * Convert byte sample to voltage according to
974 * page 269 of the Communication Interface User's Manual.
976 float_data = g_array_new(FALSE, FALSE, sizeof(float));
977 for (i = 0; i < samples; i++) {
978 voltage = (float)g_array_index(data, int8_t, i);
979 voltage = (range * voltage /
980 DLM_DIVISION_FOR_BYTE_FORMAT) + offset;
981 g_array_append_val(float_data, voltage);
984 analog.channels = g_slist_append(NULL, ch);
985 analog.num_samples = float_data->len;
986 analog.data = (float*)float_data->data;
987 analog.mq = SR_MQ_VOLTAGE;
988 analog.unit = SR_UNIT_VOLT;
990 packet.type = SR_DF_ANALOG_OLD;
991 packet.payload = &analog;
992 sr_session_send(sdi, &packet);
993 g_slist_free(analog.channels);
995 g_array_free(float_data, TRUE);
996 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1002 * Sends logic sample data off to the session bus.
1004 * @param data The raw sample data.
1005 * @ch_state Pointer to the state of the channel whose data we're processing.
1006 * @sdi The device instance.
1008 * @return SR_ERR when data is trucated, SR_OK otherwise.
1010 static int dlm_digital_samples_send(GArray *data,
1011 struct sr_dev_inst *sdi)
1013 struct dev_context *devc;
1014 struct scope_state *model_state;
1016 struct sr_datafeed_logic logic;
1017 struct sr_datafeed_packet packet;
1020 model_state = devc->model_state;
1021 samples = model_state->samples_per_frame;
1023 if (data->len < samples * sizeof(uint8_t)) {
1024 sr_err("Truncated waveform data packet received.");
1028 logic.length = samples;
1030 logic.data = data->data;
1031 packet.type = SR_DF_LOGIC;
1032 packet.payload = &logic;
1033 sr_session_send(sdi, &packet);
1035 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1041 * Attempts to query sample data from the oscilloscope in order to send it
1042 * to the session bus for further processing.
1044 * @param fd The file descriptor used as the event source.
1045 * @param revents The received events.
1046 * @param cb_data Callback data, in this case our device instance.
1048 * @return TRUE in case of success or a recoverable error,
1049 * FALSE when a fatal error was encountered.
1051 SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data)
1053 struct sr_dev_inst *sdi;
1054 struct scope_state *model_state;
1055 struct dev_context *devc;
1056 struct sr_channel *ch;
1057 struct sr_datafeed_packet packet;
1058 int chunk_len, num_bytes;
1059 static GArray *data = NULL;
1064 if (!(sdi = cb_data))
1067 if (!(devc = sdi->priv))
1070 if (!(model_state = (struct scope_state*)devc->model_state))
1073 /* Are we waiting for a response from the device? */
1074 if (!devc->data_pending)
1077 /* Check if a new query response is coming our way. */
1079 if (sr_scpi_read_begin(sdi->conn) == SR_OK)
1080 /* The 16 here accounts for the header and EOL. */
1081 data = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t),
1082 16 + model_state->samples_per_frame);
1087 /* Store incoming data. */
1088 chunk_len = sr_scpi_read_data(sdi->conn, devc->receive_buffer,
1089 RECEIVE_BUFFER_SIZE);
1090 if (chunk_len < 0) {
1091 sr_err("Error while reading data: %d", chunk_len);
1094 g_array_append_vals(data, devc->receive_buffer, chunk_len);
1096 /* Read the entire query response before processing. */
1097 if (!sr_scpi_read_complete(sdi->conn))
1100 /* We finished reading and are no longer waiting for data. */
1101 devc->data_pending = FALSE;
1103 /* Signal the beginning of a new frame if this is the first channel. */
1104 if (devc->current_channel == devc->enabled_channels) {
1105 packet.type = SR_DF_FRAME_BEGIN;
1106 sr_session_send(sdi, &packet);
1109 if (dlm_block_data_header_process(data, &num_bytes) != SR_OK) {
1110 sr_err("Encountered malformed block data header.");
1114 if (num_bytes == 0) {
1115 sr_warn("Zero-length waveform data packet received. " \
1116 "Live mode not supported yet, stopping " \
1117 "acquisition and retrying.");
1118 /* Don't care about return value here. */
1119 dlm_acquisition_stop(sdi->conn);
1120 g_array_free(data, TRUE);
1121 dlm_channel_data_request(sdi);
1125 ch = devc->current_channel->data;
1127 case SR_CHANNEL_ANALOG:
1128 if (dlm_analog_samples_send(data,
1129 &model_state->analog_states[ch->index],
1133 case SR_CHANNEL_LOGIC:
1134 if (dlm_digital_samples_send(data, sdi) != SR_OK)
1138 sr_err("Invalid channel type encountered.");
1142 g_array_free(data, TRUE);
1146 * Signal the end of this frame if this was the last enabled channel
1147 * and set the next enabled channel. Then, request its data.
1149 if (!devc->current_channel->next) {
1150 packet.type = SR_DF_FRAME_END;
1151 sr_session_send(sdi, &packet);
1152 devc->current_channel = devc->enabled_channels;
1155 * As of now we only support importing the current acquisition
1156 * data so we're going to stop at this point.
1158 sdi->driver->dev_acquisition_stop(sdi, cb_data);
1161 devc->current_channel = devc->current_channel->next;
1163 if (dlm_channel_data_request(sdi) != SR_OK) {
1164 sr_err("Failed to request acquisition data.");
1172 g_array_free(data, TRUE);