static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; struct sr_scpi_dev_inst *scpi; GVariant *beeper; if (sdi->status != SR_ST_INACTIVE) return SR_ERR; scpi = sdi->conn; if (sr_scpi_open(scpi) < 0) return SR_ERR; sdi->status = SR_ST_ACTIVE; devc = sdi->priv; scpi_cmd(sdi, devc->device->commands, SCPI_CMD_REMOTE); devc = sdi->priv; devc->beeper_was_set = FALSE; if (scpi_cmd_resp(sdi, devc->device->commands, &beeper, G_VARIANT_TYPE_BOOLEAN, SCPI_CMD_BEEPER) == SR_OK) { if (g_variant_get_boolean(beeper)) { devc->beeper_was_set = TRUE; scpi_cmd(sdi, devc->device->commands, SCPI_CMD_BEEPER_DISABLE); } g_variant_unref(beeper); } return SR_OK; }
static struct sr_dev_inst *sr_scpi_scan_resource(struct drv_context *drvc, const char *resource, const char *serialcomm, struct sr_dev_inst *(*probe_device)(struct sr_scpi_dev_inst *scpi)) { struct sr_scpi_dev_inst *scpi; struct sr_dev_inst *sdi; if (!(scpi = scpi_dev_inst_new(drvc, resource, serialcomm))) return NULL; if (sr_scpi_open(scpi) != SR_OK) { sr_info("Couldn't open SCPI device."); sr_scpi_free(scpi); return NULL; }; sdi = probe_device(scpi); sr_scpi_close(scpi); if (sdi) sdi->status = SR_ST_INACTIVE; else sr_scpi_free(scpi); return sdi; }
static int dev_open(struct sr_dev_inst *sdi) { if (sr_scpi_open(sdi->conn) != SR_OK) return SR_ERR; if (hmo_scope_state_get(sdi) != SR_OK) return SR_ERR; return SR_OK; }
static int dev_open(struct sr_dev_inst *sdi) { if (sdi->status != SR_ST_ACTIVE && sr_scpi_open(sdi->conn) != SR_OK) return SR_ERR; if (dlm_scope_state_query(sdi) != SR_OK) return SR_ERR; sdi->status = SR_ST_ACTIVE; return SR_OK; }
static int dev_open(struct sr_dev_inst *sdi) { int ret; struct sr_scpi_dev_inst *scpi = sdi->conn; if ((ret = sr_scpi_open(scpi)) < 0) { sr_err("Failed to open SCPI device: %s.", sr_strerror(ret)); return SR_ERR; } sdi->status = SR_ST_ACTIVE; return SR_OK; }
static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) { struct dev_context *devc; struct sr_dev_inst *sdi; struct sr_scpi_hw_info *hw_info; struct sr_channel *ch; long n[3]; unsigned int i; const struct rigol_ds_model *model = NULL; gchar *channel_name, **version; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response, retrying."); sr_scpi_close(scpi); sr_scpi_open(scpi); if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); return NULL; } } for (i = 0; i < ARRAY_SIZE(supported_models); i++) { if (!g_ascii_strcasecmp(hw_info->manufacturer, supported_models[i].series->vendor->full_name) && !strcmp(hw_info->model, supported_models[i].name)) { model = &supported_models[i]; break; } } if (!model) { sr_scpi_hw_info_free(hw_info); return NULL; } sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->vendor = g_strdup(model->series->vendor->name); sdi->model = g_strdup(model->name); sdi->version = g_strdup(hw_info->firmware_version); sdi->conn = scpi; sdi->driver = &rigol_ds_driver_info; sdi->inst_type = SR_INST_SCPI; sdi->serial_num = g_strdup(hw_info->serial_number); devc = g_malloc0(sizeof(struct dev_context)); devc->limit_frames = 0; devc->model = model; devc->format = model->series->format; /* DS1000 models with firmware before 0.2.4 used the old data format. */ if (model->series == SERIES(DS1000)) { version = g_strsplit(hw_info->firmware_version, ".", 0); do { if (!version[0] || !version[1] || !version[2]) break; if (version[0][0] == 0 || version[1][0] == 0 || version[2][0] == 0) break; for (i = 0; i < 3; i++) { if (sr_atol(version[i], &n[i]) != SR_OK) break; } if (i != 3) break; scpi->firmware_version = n[0] * 100 + n[1] * 10 + n[2]; if (scpi->firmware_version < 24) { sr_dbg("Found DS1000 firmware < 0.2.4, using raw data format."); devc->format = FORMAT_RAW; } break; } while (0); g_strfreev(version); } sr_scpi_hw_info_free(hw_info); devc->analog_groups = g_malloc0(sizeof(struct sr_channel_group*) * model->analog_channels); for (i = 0; i < model->analog_channels; i++) { channel_name = g_strdup_printf("CH%d", i + 1); ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name); devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group)); devc->analog_groups[i]->name = channel_name; devc->analog_groups[i]->channels = g_slist_append(NULL, ch); sdi->channel_groups = g_slist_append(sdi->channel_groups, devc->analog_groups[i]); } if (devc->model->has_digital) { devc->digital_group = g_malloc0(sizeof(struct sr_channel_group)); for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) { channel_name = g_strdup_printf("D%d", i); ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); g_free(channel_name); devc->digital_group->channels = g_slist_append( devc->digital_group->channels, ch); } devc->digital_group->name = g_strdup("LA"); sdi->channel_groups = g_slist_append(sdi->channel_groups, devc->digital_group); } for (i = 0; i < NUM_TIMEBASE; i++) { if (!memcmp(&devc->model->min_timebase, &timebases[i], sizeof(uint64_t[2]))) devc->timebases = &timebases[i]; if (!memcmp(&devc->model->series->max_timebase, &timebases[i], sizeof(uint64_t[2]))) devc->num_timebases = &timebases[i] - devc->timebases + 1; } for (i = 0; i < NUM_VDIV; i++) { if (!memcmp(&devc->model->series->min_vdiv, &vdivs[i], sizeof(uint64_t[2]))) { devc->vdivs = &vdivs[i]; devc->num_vdivs = NUM_VDIV - i; } } devc->buffer = g_malloc(ACQ_BUFFER_SIZE); devc->data = g_malloc(ACQ_BUFFER_SIZE * sizeof(float)); devc->data_source = DATA_SOURCE_LIVE; sdi->priv = devc; return sdi; }