static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { GSList *l; gboolean digital_added; struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; (void)cb_data; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; scpi = sdi->conn; devc = sdi->priv; digital_added = FALSE; g_slist_free(devc->enabled_channels); devc->enabled_channels = NULL; for (l = sdi->channels; l; l = l->next) { ch = l->data; if (!ch->enabled) continue; /* Only add a single digital channel. */ if (ch->type != SR_CHANNEL_LOGIC || !digital_added) { devc->enabled_channels = g_slist_append( devc->enabled_channels, ch); if (ch->type == SR_CHANNEL_LOGIC) digital_added = TRUE; } } if (!devc->enabled_channels) return SR_ERR; if (dlm_check_channels(devc->enabled_channels) != SR_OK) { sr_err("Invalid channel configuration specified!"); return SR_ERR_NA; } if (dlm_setup_channels(sdi) != SR_OK) { sr_err("Failed to setup channel configuration!"); return SR_ERR; } /* Request data for the first enabled channel. */ devc->current_channel = devc->enabled_channels; dlm_channel_data_request(sdi); /* Call our callback when data comes in or after 5ms. */ sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 5, dlm_data_receive, (void *)sdi); return SR_OK; }
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { GSList *l; gboolean digital_added; struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; scpi = sdi->conn; devc = sdi->priv; digital_added = FALSE; g_slist_free(devc->enabled_channels); devc->enabled_channels = NULL; for (l = sdi->channels; l; l = l->next) { ch = l->data; if (!ch->enabled) continue; /* Only add a single digital channel. */ if (ch->type != SR_CHANNEL_LOGIC || !digital_added) { devc->enabled_channels = g_slist_append( devc->enabled_channels, ch); if (ch->type == SR_CHANNEL_LOGIC) digital_added = TRUE; } } if (!devc->enabled_channels) return SR_ERR; if (hmo_check_channels(devc->enabled_channels) != SR_OK) { sr_err("Invalid channel configuration specified!"); return SR_ERR_NA; } if (hmo_setup_channels(sdi) != SR_OK) { sr_err("Failed to setup channel configuration!"); return SR_ERR; } sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi); /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX); devc->current_channel = devc->enabled_channels; return hmo_request_data(sdi); }
static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; struct dev_context *devc; scpi = sdi->conn; devc = sdi->priv; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; devc->state = START_ACQUISITION; devc->cur_acq_frame = 0; sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, gwinstek_gds_800_receive_data, (void *)sdi); return SR_OK; }
static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; struct sr_channel *ch; struct pps_channel *pch; int cmd, ret; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; devc = sdi->priv; scpi = sdi->conn; devc->cb_data = cb_data; if ((ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 10, scpi_pps_receive_data, (void *)sdi)) != SR_OK) return ret; std_session_send_df_header(sdi, LOG_PREFIX); /* Prime the pipe with the first channel's fetch. */ ch = sr_next_enabled_channel(sdi, NULL); pch = ch->priv; if ((ret = select_channel(sdi, ch)) < 0) return ret; if (pch->mq == SR_MQ_VOLTAGE) cmd = SCPI_CMD_GET_MEAS_VOLTAGE; else if (pch->mq == SR_MQ_FREQUENCY) cmd = SCPI_CMD_GET_MEAS_FREQUENCY; else if (pch->mq == SR_MQ_CURRENT) cmd = SCPI_CMD_GET_MEAS_CURRENT; else if (pch->mq == SR_MQ_POWER) cmd = SCPI_CMD_GET_MEAS_POWER; else return SR_ERR; scpi_cmd(sdi, devc->device->commands, cmd, pch->hwname); return SR_OK; }
static int dev_acquisition_start(const struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi; struct dev_context *devc; struct sr_channel *ch; struct sr_datafeed_packet packet; gboolean some_digital; GSList *l; if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; scpi = sdi->conn; devc = sdi->priv; devc->num_frames = 0; some_digital = FALSE; for (l = sdi->channels; l; l = l->next) { ch = l->data; sr_dbg("handling channel %s", ch->name); if (ch->type == SR_CHANNEL_ANALOG) { if (ch->enabled) devc->enabled_channels = g_slist_append( devc->enabled_channels, ch); if (ch->enabled != devc->analog_channels[ch->index]) { /* Enabled channel is currently disabled, or vice versa. */ if (rigol_ds_config_set(sdi, ":CHAN%d:DISP %s", ch->index + 1, ch->enabled ? "ON" : "OFF") != SR_OK) return SR_ERR; devc->analog_channels[ch->index] = ch->enabled; } } else if (ch->type == SR_CHANNEL_LOGIC) { /* Only one list entry for DS1000D series. All channels are retrieved * together when this entry is processed. */ if (ch->enabled && ( devc->model->series->protocol > PROTOCOL_V2 || !some_digital)) devc->enabled_channels = g_slist_append( devc->enabled_channels, ch); if (ch->enabled) { some_digital = TRUE; /* Turn on LA module if currently off. */ if (!devc->la_enabled) { if (rigol_ds_config_set(sdi, devc->model->series->protocol >= PROTOCOL_V4 ? ":LA:STAT ON" : ":LA:DISP ON") != SR_OK) return SR_ERR; devc->la_enabled = TRUE; } } if (ch->enabled != devc->digital_channels[ch->index]) { /* Enabled channel is currently disabled, or vice versa. */ if (rigol_ds_config_set(sdi, devc->model->series->protocol >= PROTOCOL_V4 ? ":LA:DIG%d:DISP %s" : ":DIG%d:TURN %s", ch->index, ch->enabled ? "ON" : "OFF") != SR_OK) return SR_ERR; devc->digital_channels[ch->index] = ch->enabled; } } } if (!devc->enabled_channels) return SR_ERR; /* Turn off LA module if on and no digital channels selected. */ if (devc->la_enabled && !some_digital) if (rigol_ds_config_set(sdi, devc->model->series->protocol >= PROTOCOL_V4 ? ":LA:STAT OFF" : ":LA:DISP OFF") != SR_OK) return SR_ERR; /* Set memory mode. */ if (devc->data_source == DATA_SOURCE_SEGMENTED) { sr_err("Data source 'Segmented' not yet supported"); return SR_ERR; } devc->analog_frame_size = analog_frame_size(sdi); devc->digital_frame_size = digital_frame_size(sdi); switch (devc->model->series->protocol) { case PROTOCOL_V2: if (rigol_ds_config_set(sdi, ":ACQ:MEMD LONG") != SR_OK) return SR_ERR; break; case PROTOCOL_V3: /* Apparently for the DS2000 the memory * depth can only be set in Running state - * this matches the behaviour of the UI. */ if (rigol_ds_config_set(sdi, ":RUN") != SR_OK) return SR_ERR; if (rigol_ds_config_set(sdi, ":ACQ:MDEP %d", devc->analog_frame_size) != SR_OK) return SR_ERR; if (rigol_ds_config_set(sdi, ":STOP") != SR_OK) return SR_ERR; break; default: break; } if (devc->data_source == DATA_SOURCE_LIVE) if (rigol_ds_config_set(sdi, ":RUN") != SR_OK) return SR_ERR; sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, rigol_ds_receive, (void *)sdi); std_session_send_df_header(sdi); devc->channel_entry = devc->enabled_channels; if (rigol_ds_capture_start(sdi) != SR_OK) return SR_ERR; /* Start of first frame. */ packet.type = SR_DF_FRAME_BEGIN; sr_session_send(sdi, &packet); return SR_OK; }
static int dev_acquisition_start(const struct sr_dev_inst *sdi) { GSList *l; gboolean digital_added[MAX_DIGITAL_GROUP_COUNT]; size_t group, pod_count; struct sr_channel *ch; struct dev_context *devc; struct sr_scpi_dev_inst *scpi; int ret; scpi = sdi->conn; devc = sdi->priv; /* Preset empty results. */ for (group = 0; group < ARRAY_SIZE(digital_added); group++) digital_added[group] = FALSE; g_slist_free(devc->enabled_channels); devc->enabled_channels = NULL; /* * Contruct the list of enabled channels. Determine the highest * number of digital pods involved in the acquisition. */ pod_count = 0; for (l = sdi->channels; l; l = l->next) { ch = l->data; if (!ch->enabled) continue; /* Only add a single digital channel per group (pod). */ group = ch->index / 8; if (ch->type != SR_CHANNEL_LOGIC || !digital_added[group]) { devc->enabled_channels = g_slist_append( devc->enabled_channels, ch); if (ch->type == SR_CHANNEL_LOGIC) { digital_added[group] = TRUE; if (pod_count < group + 1) pod_count = group + 1; } } } if (!devc->enabled_channels) return SR_ERR; devc->pod_count = pod_count; devc->logic_data = NULL; /* * Check constraints. Some channels can be either analog or * digital, but not both at the same time. */ if (hmo_check_channels(devc->enabled_channels) != SR_OK) { sr_err("Invalid channel configuration specified!"); ret = SR_ERR_NA; goto free_enabled; } /* * Configure the analog and digital channels and the * corresponding digital pods. */ if (hmo_setup_channels(sdi) != SR_OK) { sr_err("Failed to setup channel configuration!"); ret = SR_ERR; goto free_enabled; } /* * Start acquisition on the first enabled channel. The * receive routine will continue driving the acquisition. */ sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 50, hmo_receive_data, (void *)sdi); std_session_send_df_header(sdi); devc->current_channel = devc->enabled_channels; return hmo_request_data(sdi); free_enabled: g_slist_free(devc->enabled_channels); devc->enabled_channels = NULL; return ret; }