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
30 static const char *dlm_coupling_options[] = {
38 static const char *dlm_2ch_trigger_sources[] = {
46 /* TODO: Is BITx handled correctly or is Dx required? */
47 static const char *dlm_4ch_trigger_sources[] = {
65 /* Note: Values must correlate to the trigger_slopes values. */
66 const char *dlm_trigger_slopes[3] = {
72 const uint64_t dlm_timebases[36][2] = {
115 const uint64_t dlm_vdivs[17][2] = {
137 static const char *scope_analog_channel_names[] = {
144 static const char *scope_digital_channel_names_8[] = {
155 static const char *scope_digital_channel_names_32[] = {
190 static const struct scope_config scope_models[] = {
192 .model_id = {"710105", "710115", "710125", NULL},
193 .model_name = {"DLM2022", "DLM2032", "DLM2052", NULL},
194 .analog_channels = 2,
195 .digital_channels = 0,
198 .analog_names = &scope_analog_channel_names,
199 .digital_names = &scope_digital_channel_names_8,
201 .coupling_options = &dlm_coupling_options,
202 .trigger_sources = &dlm_2ch_trigger_sources,
208 .model_id = {"710110", "710120", "710130", NULL},
209 .model_name = {"DLM2024", "DLM2034", "DLM2054", NULL},
210 .analog_channels = 4,
211 .digital_channels = 8,
214 .analog_names = &scope_analog_channel_names,
215 .digital_names = &scope_digital_channel_names_8,
217 .coupling_options = &dlm_coupling_options,
218 .trigger_sources = &dlm_4ch_trigger_sources,
224 .model_id = {"701307", "701308", "701310", "701311",
225 "701312", "701313", NULL},
226 .model_name = {"DL9040", "DL9040L", "DL9140", "DL9140L",
227 "DL9240", "DL9240L", NULL},
228 .analog_channels = 4,
229 .digital_channels = 0,
232 .analog_names = &scope_analog_channel_names,
233 .digital_names = NULL,
235 .coupling_options = &dlm_coupling_options,
236 .trigger_sources = &dlm_4ch_trigger_sources,
242 .model_id = {"701320", "701321", NULL},
243 .model_name = {"DL9505L", "DL9510L", NULL},
244 .analog_channels = 4,
245 .digital_channels = 16,
248 .analog_names = &scope_analog_channel_names,
249 .digital_names = &scope_digital_channel_names_32,
251 .coupling_options = &dlm_coupling_options,
252 .trigger_sources = &dlm_4ch_trigger_sources,
258 .model_id = {"701330", "701331", NULL},
259 .model_name = {"DL9705L", "DL9710L", NULL},
260 .analog_channels = 4,
261 .digital_channels = 32,
264 .analog_names = &scope_analog_channel_names,
265 .digital_names = &scope_digital_channel_names_32,
267 .coupling_options = &dlm_coupling_options,
268 .trigger_sources = &dlm_4ch_trigger_sources,
276 * Prints out the state of the device as we currently know it.
278 * @param config This is the scope configuration.
279 * @param state The current scope state to print.
281 static void scope_state_dump(const struct scope_config *config,
282 struct scope_state *state)
287 for (i = 0; i < config->analog_channels; i++) {
288 tmp = sr_voltage_string(dlm_vdivs[state->analog_states[i].vdiv][0],
289 dlm_vdivs[state->analog_states[i].vdiv][1]);
290 sr_info("State of analog channel %d -> %s : %s (coupling) %s (vdiv) %2.2e (offset)",
291 i + 1, state->analog_states[i].state ? "On" : "Off",
292 (*config->coupling_options)[state->analog_states[i].coupling],
293 tmp, state->analog_states[i].vertical_offset);
296 for (i = 0; i < config->digital_channels; i++) {
297 sr_info("State of digital channel %d -> %s", i,
298 state->digital_states[i] ? "On" : "Off");
301 for (i = 0; i < config->pods; i++) {
302 sr_info("State of digital POD %d -> %s", i,
303 state->pod_states[i] ? "On" : "Off");
306 tmp = sr_period_string(dlm_timebases[state->timebase][0] *
307 dlm_timebases[state->timebase][1]);
308 sr_info("Current timebase: %s", tmp);
311 tmp = sr_samplerate_string(state->sample_rate);
312 sr_info("Current samplerate: %s", tmp);
315 sr_info("Current samples per acquisition (i.e. frame): %d",
316 state->samples_per_frame);
318 sr_info("Current trigger: %s (source), %s (slope) %.2f (offset)",
319 (*config->trigger_sources)[state->trigger_source],
320 dlm_trigger_slopes[state->trigger_slope],
321 state->horiz_triggerpos);
325 * Searches through an array of strings and returns the index to the
326 * array where a given string is located.
328 * @param value The string to search for.
329 * @param array The array of strings.
330 * @param result The index at which value is located in array. -1 on error.
332 * @return SR_ERR when value couldn't be found, SR_OK otherwise.
334 static int array_option_get(char *value, const char *(*array)[],
341 for (i = 0; (*array)[i]; i++)
342 if (!g_strcmp0(value, (*array)[i])) {
354 * This function takes a value of the form "2.000E-03", converts it to a
355 * significand / factor pair and returns the index of an array where
356 * a matching pair was found.
358 * It's a bit convoluted because of floating-point issues. The value "10.00E-09"
359 * is parsed by g_ascii_strtod() as 0.000000009999999939, for example.
360 * Therefore it's easier to break the number up into two strings and handle
363 * @param value The string to be parsed.
364 * @param array The array of s/f pairs.
365 * @param array_len The number of pairs in the array.
366 * @param result The index at which a matching pair was found.
368 * @return SR_ERR on any parsing error, SR_OK otherwise.
370 static int array_float_get(gchar *value, const uint64_t array[][2],
371 int array_len, int *result)
377 gchar ss[10], es[10];
379 memset(ss, 0, sizeof(ss));
380 memset(es, 0, sizeof(es));
382 strncpy(ss, value, 5);
383 strncpy(es, &(value[6]), 3);
385 if (sr_atof_ascii(ss, &s) != SR_OK)
387 if (sr_atoi(es, &i) != SR_OK)
390 /* Transform e.g. 10^-03 to 1000 as the array stores the inverse. */
394 * Adjust the significand/factor pair to make sure
395 * that f is a multiple of 1000.
397 while ((int)fmod(log10(f), 3) > 0) { s *= 10; f *= 10; }
399 /* Truncate s to circumvent rounding errors. */
400 s_int = (unsigned int)s;
402 for (i = 0; i < array_len; i++) {
403 if ( (s_int == array[i][0]) && (f == array[i][1]) ) {
413 * Obtains information about all analog channels from the oscilloscope.
414 * The internal state information is updated accordingly.
416 * @param sdi The device instance.
417 * @param config The device's device configuration.
418 * @param state The device's state information.
420 * @return SR_ERR on error, SR_OK otherwise.
422 static int analog_channel_state_get(const struct sr_dev_inst *sdi,
423 const struct scope_config *config,
424 struct scope_state *state)
426 struct sr_scpi_dev_inst *scpi;
429 struct sr_channel *ch;
434 for (i = 0; i < config->analog_channels; i++) {
436 if (dlm_analog_chan_state_get(scpi, i + 1,
437 &state->analog_states[i].state) != SR_OK)
440 for (l = sdi->channels; l; l = l->next) {
442 if (ch->index == i) {
443 ch->enabled = state->analog_states[i].state;
448 if (dlm_analog_chan_vdiv_get(scpi, i + 1, &response) != SR_OK)
451 if (array_float_get(response, dlm_vdivs, ARRAY_SIZE(dlm_vdivs),
458 state->analog_states[i].vdiv = j;
460 if (dlm_analog_chan_voffs_get(scpi, i + 1,
461 &state->analog_states[i].vertical_offset) != SR_OK)
464 if (dlm_analog_chan_wrange_get(scpi, i + 1,
465 &state->analog_states[i].waveform_range) != SR_OK)
468 if (dlm_analog_chan_woffs_get(scpi, i + 1,
469 &state->analog_states[i].waveform_offset) != SR_OK)
472 if (dlm_analog_chan_coupl_get(scpi, i + 1, &response) != SR_OK) {
477 if (array_option_get(response, config->coupling_options,
478 &state->analog_states[i].coupling) != SR_OK) {
489 * Obtains information about all digital channels from the oscilloscope.
490 * The internal state information is updated accordingly.
492 * @param sdi The device instance.
493 * @param config The device's device configuration.
494 * @param state The device's state information.
496 * @return SR_ERR on error, SR_OK otherwise.
498 static int digital_channel_state_get(const struct sr_dev_inst *sdi,
499 const struct scope_config *config,
500 struct scope_state *state)
502 struct sr_scpi_dev_inst *scpi;
505 struct sr_channel *ch;
509 if (!config->digital_channels) {
510 sr_warn("Tried obtaining digital channel states on a " \
511 "model without digital inputs.");
515 for (i = 0; i < config->digital_channels; i++) {
516 if (dlm_digital_chan_state_get(scpi, i + 1,
517 &state->digital_states[i]) != SR_OK) {
521 for (l = sdi->channels; l; l = l->next) {
523 if (ch->index == i + DLM_DIG_CHAN_INDEX_OFFS) {
524 ch->enabled = state->digital_states[i];
531 sr_warn("Tried obtaining pod states on a model without pods.");
535 for (i = 0; i < config->pods; i++) {
536 if (dlm_digital_pod_state_get(scpi, i + 'A',
537 &state->pod_states[i]) != SR_OK)
544 SR_PRIV int dlm_channel_state_set(const struct sr_dev_inst *sdi,
545 const int ch_index, gboolean ch_state)
548 struct sr_channel *ch;
549 struct dev_context *devc = NULL;
550 struct scope_state *state;
551 const struct scope_config *model = NULL;
552 struct sr_scpi_dev_inst *scpi;
554 gboolean *pod_enabled;
561 state = devc->model_state;
562 model = devc->model_config;
565 pod_enabled = g_malloc0(sizeof(gboolean) * model->pods);
567 for (l = sdi->channels; l; l = l->next) {
571 case SR_CHANNEL_ANALOG:
572 if (ch->index == ch_index) {
573 if (dlm_analog_chan_state_set(scpi, ch->index + 1, ch_state) != SR_OK) {
578 ch->enabled = ch_state;
579 state->analog_states[ch->index].state = ch_state;
584 case SR_CHANNEL_LOGIC:
585 i = ch->index - DLM_DIG_CHAN_INDEX_OFFS;
587 if (ch->index == ch_index) {
588 if (dlm_digital_chan_state_set(scpi, i + 1, ch_state) != SR_OK) {
593 ch->enabled = ch_state;
594 state->digital_states[i] = ch_state;
597 /* The corresponding pod has to be enabled also. */
598 pod_enabled[i / 8] |= ch->enabled;
600 /* Also check all other channels. Maybe we can disable a pod. */
601 pod_enabled[i / 8] |= ch->enabled;
609 for (i = 0; i < model->pods; i++) {
610 if (state->pod_states[i] == pod_enabled[i])
613 if (dlm_digital_pod_state_set(scpi, i + 1, pod_enabled[i]) != SR_OK) {
618 state->pod_states[i] = pod_enabled[i];
623 if ((result == SR_OK) && !chan_found)
630 * Obtains information about the sample rate from the oscilloscope.
631 * The internal state information is updated accordingly.
633 * @param sdi The device instance.
635 * @return SR_ERR on error, SR_OK otherwise.
637 SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi)
639 struct dev_context *devc;
640 struct scope_state *state;
644 state = devc->model_state;
647 * No need to find an active channel to query the sample rate:
648 * querying any channel will do, so we use channel 1 all the time.
650 if (dlm_analog_chan_srate_get(sdi->conn, 1, &tmp_float) != SR_OK)
653 state->sample_rate = tmp_float;
659 * Obtains information about the current device state from the oscilloscope,
660 * including all analog and digital channel configurations.
661 * The internal state information is updated accordingly.
663 * @param sdi The device instance.
665 * @return SR_ERR on error, SR_OK otherwise.
667 SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi)
669 struct dev_context *devc;
670 struct scope_state *state;
671 const struct scope_config *config;
677 config = devc->model_config;
678 state = devc->model_state;
680 if (analog_channel_state_get(sdi, config, state) != SR_OK)
683 if (digital_channel_state_get(sdi, config, state) != SR_OK)
686 if (dlm_timebase_get(sdi->conn, &response) != SR_OK)
689 if (array_float_get(response, dlm_timebases,
690 ARRAY_SIZE(dlm_timebases), &i) != SR_OK) {
698 if (dlm_horiz_trigger_pos_get(sdi->conn, &tmp_float) != SR_OK)
701 /* TODO: Check if the calculation makes sense for the DLM. */
702 state->horiz_triggerpos = tmp_float /
703 (((double)dlm_timebases[state->timebase][0] /
704 dlm_timebases[state->timebase][1]) * config->num_xdivs);
705 state->horiz_triggerpos -= 0.5;
706 state->horiz_triggerpos *= -1;
708 if (dlm_trigger_source_get(sdi->conn, &response) != SR_OK) {
713 if (array_option_get(response, config->trigger_sources,
714 &state->trigger_source) != SR_OK) {
721 if (dlm_trigger_slope_get(sdi->conn, &i) != SR_OK)
724 state->trigger_slope = i;
726 if (dlm_acq_length_get(sdi->conn, &state->samples_per_frame) != SR_OK) {
727 sr_err("Failed to query acquisition length.");
731 dlm_sample_rate_query(sdi);
733 scope_state_dump(config, state);
739 * Creates a new device state structure.
741 * @param config The device configuration to use.
743 * @return The newly allocated scope_state struct.
745 static struct scope_state *dlm_scope_state_new(const struct scope_config *config)
747 struct scope_state *state;
749 state = g_malloc0(sizeof(struct scope_state));
751 state->analog_states = g_malloc0(config->analog_channels *
752 sizeof(struct analog_channel_state));
754 state->digital_states = g_malloc0(config->digital_channels *
757 state->pod_states = g_malloc0(config->pods * sizeof(gboolean));
763 * Frees the memory that was allocated by a call to dlm_scope_state_new().
765 * @param state The device state structure whose memory is to be freed.
767 SR_PRIV void dlm_scope_state_destroy(struct scope_state *state)
769 g_free(state->analog_states);
770 g_free(state->digital_states);
771 g_free(state->pod_states);
775 SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index)
782 for (i = 0; i < ARRAY_SIZE(scope_models); i++) {
783 for (j = 0; scope_models[i].model_id[j]; j++) {
784 if (!strcmp(model_id, scope_models[i].model_id[j])) {
786 *model_name = (char *)scope_models[i].model_name[j];
790 if (*model_index != -1)
794 if (*model_index == -1) {
795 sr_err("Found unsupported DLM device with model identifier %s.",
804 * Attempts to initialize a DL/DLM device and prepares internal structures
805 * if a suitable device was found.
807 * @param sdi The device instance.
809 SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
813 struct sr_channel *ch;
814 struct dev_context *devc;
818 devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
819 scope_models[model_index].analog_channels);
821 devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
822 scope_models[model_index].pods);
824 /* Add analog channels, each in its own group. */
825 for (i = 0; i < scope_models[model_index].analog_channels; i++) {
826 ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
827 (*scope_models[model_index].analog_names)[i]);
829 devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
831 devc->analog_groups[i]->name = g_strdup(
832 (char *)(*scope_models[model_index].analog_names)[i]);
833 devc->analog_groups[i]->channels = g_slist_append(NULL, ch);
835 sdi->channel_groups = g_slist_append(sdi->channel_groups,
836 devc->analog_groups[i]);
839 /* Add digital channel groups. */
840 for (i = 0; i < scope_models[model_index].pods; i++) {
841 g_snprintf(tmp, sizeof(tmp), "POD%d", i);
843 devc->digital_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
844 if (!devc->digital_groups[i])
845 return SR_ERR_MALLOC;
847 devc->digital_groups[i]->name = g_strdup(tmp);
848 sdi->channel_groups = g_slist_append(sdi->channel_groups,
849 devc->digital_groups[i]);
852 /* Add digital channels. */
853 for (i = 0; i < scope_models[model_index].digital_channels; i++) {
854 ch = sr_channel_new(sdi, DLM_DIG_CHAN_INDEX_OFFS + i,
855 SR_CHANNEL_LOGIC, TRUE,
856 (*scope_models[model_index].digital_names)[i]);
858 devc->digital_groups[i / 8]->channels = g_slist_append(
859 devc->digital_groups[i / 8]->channels, ch);
861 devc->model_config = &scope_models[model_index];
862 devc->frame_limit = 0;
864 if (!(devc->model_state = dlm_scope_state_new(devc->model_config)))
865 return SR_ERR_MALLOC;
867 /* Disable non-standard response behavior. */
868 if (dlm_response_headers_set(sdi->conn, FALSE) != SR_OK)
874 SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi)
876 struct dev_context *devc;
877 struct sr_channel *ch;
881 ch = devc->current_channel->data;
884 case SR_CHANNEL_ANALOG:
885 result = dlm_analog_data_get(sdi->conn, ch->index + 1);
887 case SR_CHANNEL_LOGIC:
888 result = dlm_digital_data_get(sdi->conn);
891 sr_err("Invalid channel type encountered (%d).",
897 devc->data_pending = TRUE;
899 devc->data_pending = FALSE;
905 * Reads and removes the block data header from a given data input.
906 * Format is #ndddd... with n being the number of decimal digits d.
907 * The string dddd... contains the decimal-encoded length of the data.
908 * Example: #9000000013 would yield a length of 13 bytes.
910 * @param data The input data.
911 * @param len The determined input data length.
913 static int dlm_block_data_header_process(GArray *data, int *len)
918 if (g_array_index(data, gchar, 0) != '#')
921 n = (uint8_t)(g_array_index(data, gchar, 1) - '0');
923 for (i = 0; i < n; i++)
924 s[i] = g_array_index(data, gchar, 2 + i);
927 if (sr_atoi(s, len) != SR_OK)
930 g_array_remove_range(data, 0, 2 + n);
936 * Turns raw sample data into voltages and sends them off to the session bus.
938 * @param data The raw sample data.
939 * @ch_state Pointer to the state of the channel whose data we're processing.
940 * @sdi The device instance.
942 * @return SR_ERR when data is trucated, SR_OK otherwise.
944 static int dlm_analog_samples_send(GArray *data,
945 struct analog_channel_state *ch_state,
946 struct sr_dev_inst *sdi)
949 float voltage, range, offset;
951 struct dev_context *devc;
952 struct scope_state *model_state;
953 struct sr_channel *ch;
954 struct sr_datafeed_analog analog;
955 struct sr_datafeed_packet packet;
958 model_state = devc->model_state;
959 samples = model_state->samples_per_frame;
960 ch = devc->current_channel->data;
962 if (data->len < samples * sizeof(uint8_t)) {
963 sr_err("Truncated waveform data packet received.");
967 range = ch_state->waveform_range;
968 offset = ch_state->waveform_offset;
971 * Convert byte sample to voltage according to
972 * page 269 of the Communication Interface User's Manual.
974 float_data = g_array_new(FALSE, FALSE, sizeof(float));
975 for (i = 0; i < samples; i++) {
976 voltage = (float)g_array_index(data, int8_t, i);
977 voltage = (range * voltage /
978 DLM_DIVISION_FOR_BYTE_FORMAT) + offset;
979 g_array_append_val(float_data, voltage);
982 analog.channels = g_slist_append(NULL, ch);
983 analog.num_samples = float_data->len;
984 analog.data = (float*)float_data->data;
985 analog.mq = SR_MQ_VOLTAGE;
986 analog.unit = SR_UNIT_VOLT;
988 packet.type = SR_DF_ANALOG;
989 packet.payload = &analog;
990 sr_session_send(sdi, &packet);
991 g_slist_free(analog.channels);
993 g_array_free(float_data, TRUE);
994 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1000 * Sends logic sample data off to the session bus.
1002 * @param data The raw sample data.
1003 * @ch_state Pointer to the state of the channel whose data we're processing.
1004 * @sdi The device instance.
1006 * @return SR_ERR when data is trucated, SR_OK otherwise.
1008 static int dlm_digital_samples_send(GArray *data,
1009 struct sr_dev_inst *sdi)
1011 struct dev_context *devc;
1012 struct scope_state *model_state;
1014 struct sr_datafeed_logic logic;
1015 struct sr_datafeed_packet packet;
1018 model_state = devc->model_state;
1019 samples = model_state->samples_per_frame;
1021 if (data->len < samples * sizeof(uint8_t)) {
1022 sr_err("Truncated waveform data packet received.");
1026 logic.length = samples;
1028 logic.data = data->data;
1029 packet.type = SR_DF_LOGIC;
1030 packet.payload = &logic;
1031 sr_session_send(sdi, &packet);
1033 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1039 * Attempts to query sample data from the oscilloscope in order to send it
1040 * to the session bus for further processing.
1042 * @param fd The file descriptor used as the event source.
1043 * @param revents The received events.
1044 * @param cb_data Callback data, in this case our device instance.
1046 * @return TRUE in case of success or a recoverable error,
1047 * FALSE when a fatal error was encountered.
1049 SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data)
1051 struct sr_dev_inst *sdi;
1052 struct scope_state *model_state;
1053 struct dev_context *devc;
1054 struct sr_channel *ch;
1055 struct sr_datafeed_packet packet;
1056 int chunk_len, num_bytes;
1057 static GArray *data = NULL;
1062 if (!(sdi = cb_data))
1065 if (!(devc = sdi->priv))
1068 if (!(model_state = (struct scope_state*)devc->model_state))
1071 /* Are we waiting for a response from the device? */
1072 if (!devc->data_pending)
1075 /* Check if a new query response is coming our way. */
1077 if (sr_scpi_read_begin(sdi->conn) == SR_OK)
1078 /* The 16 here accounts for the header and EOL. */
1079 data = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t),
1080 16 + model_state->samples_per_frame);
1085 /* Store incoming data. */
1086 chunk_len = sr_scpi_read_data(sdi->conn, devc->receive_buffer,
1087 RECEIVE_BUFFER_SIZE);
1088 if (chunk_len < 0) {
1089 sr_err("Error while reading data: %d", chunk_len);
1092 g_array_append_vals(data, devc->receive_buffer, chunk_len);
1094 /* Read the entire query response before processing. */
1095 if (!sr_scpi_read_complete(sdi->conn))
1098 /* We finished reading and are no longer waiting for data. */
1099 devc->data_pending = FALSE;
1101 /* Signal the beginning of a new frame if this is the first channel. */
1102 if (devc->current_channel == devc->enabled_channels) {
1103 packet.type = SR_DF_FRAME_BEGIN;
1104 sr_session_send(sdi, &packet);
1107 if (dlm_block_data_header_process(data, &num_bytes) != SR_OK) {
1108 sr_err("Encountered malformed block data header.");
1112 if (num_bytes == 0) {
1113 sr_warn("Zero-length waveform data packet received. " \
1114 "Live mode not supported yet, stopping " \
1115 "acquisition and retrying.");
1116 /* Don't care about return value here. */
1117 dlm_acquisition_stop(sdi->conn);
1118 g_array_free(data, TRUE);
1119 dlm_channel_data_request(sdi);
1123 ch = devc->current_channel->data;
1125 case SR_CHANNEL_ANALOG:
1126 if (dlm_analog_samples_send(data,
1127 &model_state->analog_states[ch->index],
1131 case SR_CHANNEL_LOGIC:
1132 if (dlm_digital_samples_send(data, sdi) != SR_OK)
1136 sr_err("Invalid channel type encountered.");
1140 g_array_free(data, TRUE);
1144 * Signal the end of this frame if this was the last enabled channel
1145 * and set the next enabled channel. Then, request its data.
1147 if (!devc->current_channel->next) {
1148 packet.type = SR_DF_FRAME_END;
1149 sr_session_send(sdi, &packet);
1150 devc->current_channel = devc->enabled_channels;
1153 * As of now we only support importing the current acquisition
1154 * data so we're going to stop at this point.
1156 sdi->driver->dev_acquisition_stop(sdi, cb_data);
1159 devc->current_channel = devc->current_channel->next;
1161 if (dlm_channel_data_request(sdi) != SR_OK) {
1162 sr_err("Failed to request acquisition data.");
1170 g_array_free(data, TRUE);