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)
380 gchar ss[10], es[10];
382 memset(ss, 0, sizeof(ss));
383 memset(es, 0, sizeof(es));
385 /* Get index of the separating 'E' character and break up the string. */
386 pos = strcspn(value, "E");
388 strncpy(ss, value, pos);
389 strncpy(es, &(value[pos+1]), 3);
391 if (sr_atof_ascii(ss, &s) != SR_OK)
393 if (sr_atoi(es, &e) != SR_OK)
396 /* Transform e.g. 10^-03 to 1000 as the array stores the inverse. */
400 * Adjust the significand/factor pair to make sure
401 * that f is a multiple of 1000.
403 while ((int)fmod(log10(f), 3) > 0) {
412 /* Truncate s to circumvent rounding errors. */
413 s_int = (unsigned int)s;
415 for (i = 0; i < array_len; i++) {
416 if ((s_int == array[i][0]) && (f == array[i][1])) {
426 * Obtains information about all analog channels from the oscilloscope.
427 * The internal state information is updated accordingly.
429 * @param sdi The device instance.
430 * @param config The device's device configuration.
431 * @param state The device's state information.
433 * @return SR_ERR on error, SR_OK otherwise.
435 static int analog_channel_state_get(const struct sr_dev_inst *sdi,
436 const struct scope_config *config,
437 struct scope_state *state)
439 struct sr_scpi_dev_inst *scpi;
442 struct sr_channel *ch;
447 for (i = 0; i < config->analog_channels; i++) {
449 if (dlm_analog_chan_state_get(scpi, i + 1,
450 &state->analog_states[i].state) != SR_OK)
453 for (l = sdi->channels; l; l = l->next) {
455 if (ch->index == i) {
456 ch->enabled = state->analog_states[i].state;
461 if (dlm_analog_chan_vdiv_get(scpi, i + 1, &response) != SR_OK)
464 if (array_float_get(response, dlm_vdivs, ARRAY_SIZE(dlm_vdivs),
471 state->analog_states[i].vdiv = j;
473 if (dlm_analog_chan_voffs_get(scpi, i + 1,
474 &state->analog_states[i].vertical_offset) != SR_OK)
477 if (dlm_analog_chan_wrange_get(scpi, i + 1,
478 &state->analog_states[i].waveform_range) != SR_OK)
481 if (dlm_analog_chan_woffs_get(scpi, i + 1,
482 &state->analog_states[i].waveform_offset) != SR_OK)
485 if (dlm_analog_chan_coupl_get(scpi, i + 1, &response) != SR_OK) {
490 if (array_option_get(response, config->coupling_options,
491 &state->analog_states[i].coupling) != SR_OK) {
502 * Obtains information about all digital channels from the oscilloscope.
503 * The internal state information is updated accordingly.
505 * @param sdi The device instance.
506 * @param config The device's device configuration.
507 * @param state The device's state information.
509 * @return SR_ERR on error, SR_OK otherwise.
511 static int digital_channel_state_get(const struct sr_dev_inst *sdi,
512 const struct scope_config *config,
513 struct scope_state *state)
515 struct sr_scpi_dev_inst *scpi;
518 struct sr_channel *ch;
522 if (!config->digital_channels) {
523 sr_warn("Tried obtaining digital channel states on a " \
524 "model without digital inputs.");
528 for (i = 0; i < config->digital_channels; i++) {
529 if (dlm_digital_chan_state_get(scpi, i + 1,
530 &state->digital_states[i]) != SR_OK) {
534 for (l = sdi->channels; l; l = l->next) {
536 if (ch->index == i + DLM_DIG_CHAN_INDEX_OFFS) {
537 ch->enabled = state->digital_states[i];
544 sr_warn("Tried obtaining pod states on a model without pods.");
548 for (i = 0; i < config->pods; i++) {
549 if (dlm_digital_pod_state_get(scpi, i + 'A',
550 &state->pod_states[i]) != SR_OK)
557 SR_PRIV int dlm_channel_state_set(const struct sr_dev_inst *sdi,
558 const int ch_index, gboolean ch_state)
561 struct sr_channel *ch;
562 struct dev_context *devc = NULL;
563 struct scope_state *state;
564 const struct scope_config *model = NULL;
565 struct sr_scpi_dev_inst *scpi;
567 gboolean *pod_enabled;
574 state = devc->model_state;
575 model = devc->model_config;
578 pod_enabled = g_malloc0(sizeof(gboolean) * model->pods);
580 for (l = sdi->channels; l; l = l->next) {
584 case SR_CHANNEL_ANALOG:
585 if (ch->index == ch_index) {
586 if (dlm_analog_chan_state_set(scpi, ch->index + 1, ch_state) != SR_OK) {
591 ch->enabled = ch_state;
592 state->analog_states[ch->index].state = ch_state;
597 case SR_CHANNEL_LOGIC:
598 i = ch->index - DLM_DIG_CHAN_INDEX_OFFS;
600 if (ch->index == ch_index) {
601 if (dlm_digital_chan_state_set(scpi, i + 1, ch_state) != SR_OK) {
606 ch->enabled = ch_state;
607 state->digital_states[i] = ch_state;
610 /* The corresponding pod has to be enabled also. */
611 pod_enabled[i / 8] |= ch->enabled;
613 /* Also check all other channels. Maybe we can disable a pod. */
614 pod_enabled[i / 8] |= ch->enabled;
622 for (i = 0; i < model->pods; i++) {
623 if (state->pod_states[i] == pod_enabled[i])
626 if (dlm_digital_pod_state_set(scpi, i + 1, pod_enabled[i]) != SR_OK) {
631 state->pod_states[i] = pod_enabled[i];
636 if ((result == SR_OK) && !chan_found)
643 * Obtains information about the sample rate from the oscilloscope.
644 * The internal state information is updated accordingly.
646 * @param sdi The device instance.
648 * @return SR_ERR on error, SR_OK otherwise.
650 SR_PRIV int dlm_sample_rate_query(const struct sr_dev_inst *sdi)
652 struct dev_context *devc;
653 struct scope_state *state;
657 state = devc->model_state;
660 * No need to find an active channel to query the sample rate:
661 * querying any channel will do, so we use channel 1 all the time.
663 if (dlm_analog_chan_srate_get(sdi->conn, 1, &tmp_float) != SR_OK)
666 state->sample_rate = tmp_float;
672 * Obtains information about the current device state from the oscilloscope,
673 * including all analog and digital channel configurations.
674 * The internal state information is updated accordingly.
676 * @param sdi The device instance.
678 * @return SR_ERR on error, SR_OK otherwise.
680 SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi)
682 struct dev_context *devc;
683 struct scope_state *state;
684 const struct scope_config *config;
690 config = devc->model_config;
691 state = devc->model_state;
693 if (analog_channel_state_get(sdi, config, state) != SR_OK)
696 if (digital_channel_state_get(sdi, config, state) != SR_OK)
699 if (dlm_timebase_get(sdi->conn, &response) != SR_OK)
702 if (array_float_get(response, dlm_timebases,
703 ARRAY_SIZE(dlm_timebases), &i) != SR_OK) {
711 if (dlm_horiz_trigger_pos_get(sdi->conn, &tmp_float) != SR_OK)
714 /* TODO: Check if the calculation makes sense for the DLM. */
715 state->horiz_triggerpos = tmp_float /
716 (((double)dlm_timebases[state->timebase][0] /
717 dlm_timebases[state->timebase][1]) * config->num_xdivs);
718 state->horiz_triggerpos -= 0.5;
719 state->horiz_triggerpos *= -1;
721 if (dlm_trigger_source_get(sdi->conn, &response) != SR_OK) {
726 if (array_option_get(response, config->trigger_sources,
727 &state->trigger_source) != SR_OK) {
734 if (dlm_trigger_slope_get(sdi->conn, &i) != SR_OK)
737 state->trigger_slope = i;
739 if (dlm_acq_length_get(sdi->conn, &state->samples_per_frame) != SR_OK) {
740 sr_err("Failed to query acquisition length.");
744 dlm_sample_rate_query(sdi);
746 scope_state_dump(config, state);
752 * Creates a new device state structure.
754 * @param config The device configuration to use.
756 * @return The newly allocated scope_state struct.
758 static struct scope_state *dlm_scope_state_new(const struct scope_config *config)
760 struct scope_state *state;
762 state = g_malloc0(sizeof(struct scope_state));
764 state->analog_states = g_malloc0(config->analog_channels *
765 sizeof(struct analog_channel_state));
767 state->digital_states = g_malloc0(config->digital_channels *
770 state->pod_states = g_malloc0(config->pods * sizeof(gboolean));
776 * Frees the memory that was allocated by a call to dlm_scope_state_new().
778 * @param state The device state structure whose memory is to be freed.
780 SR_PRIV void dlm_scope_state_destroy(struct scope_state *state)
782 g_free(state->analog_states);
783 g_free(state->digital_states);
784 g_free(state->pod_states);
788 SR_PRIV int dlm_model_get(char *model_id, char **model_name, int *model_index)
795 for (i = 0; i < ARRAY_SIZE(scope_models); i++) {
796 for (j = 0; scope_models[i].model_id[j]; j++) {
797 if (!strcmp(model_id, scope_models[i].model_id[j])) {
799 *model_name = (char *)scope_models[i].model_name[j];
803 if (*model_index != -1)
807 if (*model_index == -1) {
808 sr_err("Found unsupported DLM device with model identifier %s.",
817 * Attempts to initialize a DL/DLM device and prepares internal structures
818 * if a suitable device was found.
820 * @param sdi The device instance.
822 SR_PRIV int dlm_device_init(struct sr_dev_inst *sdi, int model_index)
826 struct sr_channel *ch;
827 struct dev_context *devc;
831 devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) *
832 scope_models[model_index].analog_channels);
834 devc->digital_groups = g_malloc0(sizeof(struct sr_channel_group*) *
835 scope_models[model_index].pods);
837 /* Add analog channels, each in its own group. */
838 for (i = 0; i < scope_models[model_index].analog_channels; i++) {
839 ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE,
840 (*scope_models[model_index].analog_names)[i]);
842 devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
844 devc->analog_groups[i]->name = g_strdup(
845 (char *)(*scope_models[model_index].analog_names)[i]);
846 devc->analog_groups[i]->channels = g_slist_append(NULL, ch);
848 sdi->channel_groups = g_slist_append(sdi->channel_groups,
849 devc->analog_groups[i]);
852 /* Add digital channel groups. */
853 for (i = 0; i < scope_models[model_index].pods; i++) {
854 g_snprintf(tmp, sizeof(tmp), "POD%d", i);
856 devc->digital_groups[i] = g_malloc0(sizeof(struct sr_channel_group));
857 if (!devc->digital_groups[i])
858 return SR_ERR_MALLOC;
860 devc->digital_groups[i]->name = g_strdup(tmp);
861 sdi->channel_groups = g_slist_append(sdi->channel_groups,
862 devc->digital_groups[i]);
865 /* Add digital channels. */
866 for (i = 0; i < scope_models[model_index].digital_channels; i++) {
867 ch = sr_channel_new(sdi, DLM_DIG_CHAN_INDEX_OFFS + i,
868 SR_CHANNEL_LOGIC, TRUE,
869 (*scope_models[model_index].digital_names)[i]);
871 devc->digital_groups[i / 8]->channels = g_slist_append(
872 devc->digital_groups[i / 8]->channels, ch);
874 devc->model_config = &scope_models[model_index];
875 devc->frame_limit = 0;
877 if (!(devc->model_state = dlm_scope_state_new(devc->model_config)))
878 return SR_ERR_MALLOC;
880 /* Disable non-standard response behavior. */
881 if (dlm_response_headers_set(sdi->conn, FALSE) != SR_OK)
887 SR_PRIV int dlm_channel_data_request(const struct sr_dev_inst *sdi)
889 struct dev_context *devc;
890 struct sr_channel *ch;
894 ch = devc->current_channel->data;
897 case SR_CHANNEL_ANALOG:
898 result = dlm_analog_data_get(sdi->conn, ch->index + 1);
900 case SR_CHANNEL_LOGIC:
901 result = dlm_digital_data_get(sdi->conn);
904 sr_err("Invalid channel type encountered (%d).",
910 devc->data_pending = TRUE;
912 devc->data_pending = FALSE;
918 * Reads and removes the block data header from a given data input.
919 * Format is #ndddd... with n being the number of decimal digits d.
920 * The string dddd... contains the decimal-encoded length of the data.
921 * Example: #9000000013 would yield a length of 13 bytes.
923 * @param data The input data.
924 * @param len The determined input data length.
926 static int dlm_block_data_header_process(GArray *data, int *len)
931 if (g_array_index(data, gchar, 0) != '#')
934 n = (uint8_t)(g_array_index(data, gchar, 1) - '0');
936 for (i = 0; i < n; i++)
937 s[i] = g_array_index(data, gchar, 2 + i);
940 if (sr_atoi(s, len) != SR_OK)
943 g_array_remove_range(data, 0, 2 + n);
949 * Turns raw sample data into voltages and sends them off to the session bus.
951 * @param data The raw sample data.
952 * @ch_state Pointer to the state of the channel whose data we're processing.
953 * @sdi The device instance.
955 * @return SR_ERR when data is trucated, SR_OK otherwise.
957 static int dlm_analog_samples_send(GArray *data,
958 struct analog_channel_state *ch_state,
959 struct sr_dev_inst *sdi)
962 float voltage, range, offset;
964 struct dev_context *devc;
965 struct scope_state *model_state;
966 struct sr_channel *ch;
967 struct sr_datafeed_analog_old analog;
968 struct sr_datafeed_packet packet;
971 model_state = devc->model_state;
972 samples = model_state->samples_per_frame;
973 ch = devc->current_channel->data;
975 if (data->len < samples * sizeof(uint8_t)) {
976 sr_err("Truncated waveform data packet received.");
980 range = ch_state->waveform_range;
981 offset = ch_state->waveform_offset;
984 * Convert byte sample to voltage according to
985 * page 269 of the Communication Interface User's Manual.
987 float_data = g_array_new(FALSE, FALSE, sizeof(float));
988 for (i = 0; i < samples; i++) {
989 voltage = (float)g_array_index(data, int8_t, i);
990 voltage = (range * voltage /
991 DLM_DIVISION_FOR_BYTE_FORMAT) + offset;
992 g_array_append_val(float_data, voltage);
995 analog.channels = g_slist_append(NULL, ch);
996 analog.num_samples = float_data->len;
997 analog.data = (float*)float_data->data;
998 analog.mq = SR_MQ_VOLTAGE;
999 analog.unit = SR_UNIT_VOLT;
1001 packet.type = SR_DF_ANALOG_OLD;
1002 packet.payload = &analog;
1003 sr_session_send(sdi, &packet);
1004 g_slist_free(analog.channels);
1006 g_array_free(float_data, TRUE);
1007 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1013 * Sends logic sample data off to the session bus.
1015 * @param data The raw sample data.
1016 * @ch_state Pointer to the state of the channel whose data we're processing.
1017 * @sdi The device instance.
1019 * @return SR_ERR when data is trucated, SR_OK otherwise.
1021 static int dlm_digital_samples_send(GArray *data,
1022 struct sr_dev_inst *sdi)
1024 struct dev_context *devc;
1025 struct scope_state *model_state;
1027 struct sr_datafeed_logic logic;
1028 struct sr_datafeed_packet packet;
1031 model_state = devc->model_state;
1032 samples = model_state->samples_per_frame;
1034 if (data->len < samples * sizeof(uint8_t)) {
1035 sr_err("Truncated waveform data packet received.");
1039 logic.length = samples;
1041 logic.data = data->data;
1042 packet.type = SR_DF_LOGIC;
1043 packet.payload = &logic;
1044 sr_session_send(sdi, &packet);
1046 g_array_remove_range(data, 0, samples * sizeof(uint8_t));
1052 * Attempts to query sample data from the oscilloscope in order to send it
1053 * to the session bus for further processing.
1055 * @param fd The file descriptor used as the event source.
1056 * @param revents The received events.
1057 * @param cb_data Callback data, in this case our device instance.
1059 * @return TRUE in case of success or a recoverable error,
1060 * FALSE when a fatal error was encountered.
1062 SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data)
1064 struct sr_dev_inst *sdi;
1065 struct scope_state *model_state;
1066 struct dev_context *devc;
1067 struct sr_channel *ch;
1068 struct sr_datafeed_packet packet;
1069 int chunk_len, num_bytes;
1070 static GArray *data = NULL;
1075 if (!(sdi = cb_data))
1078 if (!(devc = sdi->priv))
1081 if (!(model_state = (struct scope_state*)devc->model_state))
1084 /* Are we waiting for a response from the device? */
1085 if (!devc->data_pending)
1088 /* Check if a new query response is coming our way. */
1090 if (sr_scpi_read_begin(sdi->conn) == SR_OK)
1091 /* The 16 here accounts for the header and EOL. */
1092 data = g_array_sized_new(FALSE, FALSE, sizeof(uint8_t),
1093 16 + model_state->samples_per_frame);
1098 /* Store incoming data. */
1099 chunk_len = sr_scpi_read_data(sdi->conn, devc->receive_buffer,
1100 RECEIVE_BUFFER_SIZE);
1101 if (chunk_len < 0) {
1102 sr_err("Error while reading data: %d", chunk_len);
1105 g_array_append_vals(data, devc->receive_buffer, chunk_len);
1107 /* Read the entire query response before processing. */
1108 if (!sr_scpi_read_complete(sdi->conn))
1111 /* We finished reading and are no longer waiting for data. */
1112 devc->data_pending = FALSE;
1114 /* Signal the beginning of a new frame if this is the first channel. */
1115 if (devc->current_channel == devc->enabled_channels) {
1116 packet.type = SR_DF_FRAME_BEGIN;
1117 sr_session_send(sdi, &packet);
1120 if (dlm_block_data_header_process(data, &num_bytes) != SR_OK) {
1121 sr_err("Encountered malformed block data header.");
1125 if (num_bytes == 0) {
1126 sr_warn("Zero-length waveform data packet received. " \
1127 "Live mode not supported yet, stopping " \
1128 "acquisition and retrying.");
1129 /* Don't care about return value here. */
1130 dlm_acquisition_stop(sdi->conn);
1131 g_array_free(data, TRUE);
1132 dlm_channel_data_request(sdi);
1136 ch = devc->current_channel->data;
1138 case SR_CHANNEL_ANALOG:
1139 if (dlm_analog_samples_send(data,
1140 &model_state->analog_states[ch->index],
1144 case SR_CHANNEL_LOGIC:
1145 if (dlm_digital_samples_send(data, sdi) != SR_OK)
1149 sr_err("Invalid channel type encountered.");
1153 g_array_free(data, TRUE);
1157 * Signal the end of this frame if this was the last enabled channel
1158 * and set the next enabled channel. Then, request its data.
1160 if (!devc->current_channel->next) {
1161 packet.type = SR_DF_FRAME_END;
1162 sr_session_send(sdi, &packet);
1163 devc->current_channel = devc->enabled_channels;
1166 * As of now we only support importing the current acquisition
1167 * data so we're going to stop at this point.
1169 sdi->driver->dev_acquisition_stop(sdi);
1172 devc->current_channel = devc->current_channel->next;
1174 if (dlm_channel_data_request(sdi) != SR_OK) {
1175 sr_err("Failed to request acquisition data.");
1183 g_array_free(data, TRUE);