static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi) { struct sr_dev_inst *sdi; struct dev_context *devc; struct sr_scpi_hw_info *hw_info; char *model_name; int model_index; sdi = NULL; devc = NULL; hw_info = NULL; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); goto fail; } if (strcmp(hw_info->manufacturer, MANUFACTURER_ID) != 0) goto fail; if (dlm_model_get(hw_info->model, &model_name, &model_index) != SR_OK) goto fail; sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_ACTIVE; sdi->vendor = g_strdup(MANUFACTURER_NAME); sdi->model = g_strdup(model_name); sdi->version = g_strdup(hw_info->firmware_version); sdi->serial_num = g_strdup(hw_info->serial_number); sr_scpi_hw_info_free(hw_info); hw_info = NULL; devc = g_malloc0(sizeof(struct dev_context)); sdi->driver = &yokogawa_dlm_driver_info; sdi->priv = devc; sdi->inst_type = SR_INST_SCPI; sdi->conn = scpi; if (dlm_device_init(sdi, model_index) != SR_OK) goto fail; sr_scpi_close(sdi->conn); sdi->status = SR_ST_INACTIVE; return sdi; fail: if (hw_info) sr_scpi_hw_info_free(hw_info); if (sdi) sr_dev_inst_free(sdi); g_free(devc); return NULL; }
static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi) { struct sr_dev_inst *sdi; struct dev_context *devc; struct sr_scpi_hw_info *hw_info; sdi = NULL; devc = NULL; hw_info = NULL; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); goto fail; } if (check_manufacturer(hw_info->manufacturer) != SR_OK) goto fail; sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_ACTIVE; sdi->vendor = g_strdup(hw_info->manufacturer); sdi->model = g_strdup(hw_info->model); sdi->version = g_strdup(hw_info->firmware_version); sdi->serial_num = g_strdup(hw_info->serial_number); sdi->driver = &hameg_hmo_driver_info; sdi->inst_type = SR_INST_SCPI; sdi->conn = scpi; sr_scpi_hw_info_free(hw_info); hw_info = NULL; devc = g_malloc0(sizeof(struct dev_context)); sdi->priv = devc; if (hmo_init_device(sdi) != SR_OK) goto fail; sr_scpi_close(sdi->conn); sdi->status = SR_ST_INACTIVE; return sdi; fail: if (hw_info) sr_scpi_hw_info_free(hw_info); if (sdi) sr_dev_inst_free(sdi); g_free(devc); return NULL; }
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_group *cg; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); return NULL; } if (strcmp(hw_info->manufacturer, "GW") != 0 || strncmp(hw_info->model, "GDS-8", 5) != 0) { sr_scpi_hw_info_free(hw_info); return NULL; } sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->vendor = g_strdup(hw_info->manufacturer); sdi->model = g_strdup(hw_info->model); sdi->version = g_strdup(hw_info->firmware_version); sdi->conn = scpi; sdi->driver = &gwinstek_gds_800_driver_info; sdi->inst_type = SR_INST_SCPI; sdi->serial_num = g_strdup(hw_info->serial_number); sdi->channels = NULL; sdi->channel_groups = NULL; sr_scpi_hw_info_free(hw_info); devc = g_malloc0(sizeof(struct dev_context)); devc->frame_limit = 1; devc->sample_rate = 0.; devc->df_started = FALSE; sdi->priv = devc; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1"); sr_channel_new(sdi, 1, SR_CHANNEL_ANALOG, TRUE, "CH2"); cg = g_malloc0(sizeof(struct sr_channel_group)); cg->name = g_strdup(""); cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 0)); cg->channels = g_slist_append(cg->channels, g_slist_nth_data(sdi->channels, 1)); cg->priv = NULL; sdi->channel_groups = g_slist_append(NULL, cg); return sdi; }
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_group *cg; struct sr_channel *ch; const struct scpi_pps *device; struct pps_channel *pch; struct channel_spec *channels; struct channel_group_spec *channel_groups, *cgs; struct pps_channel_group *pcg; GRegex *model_re; GMatchInfo *model_mi; GSList *l; uint64_t mask; unsigned int num_channels, num_channel_groups, ch_num, ch_idx, i, j; int ret; const char *vendor; char ch_name[16]; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); return NULL; } device = NULL; for (i = 0; i < num_pps_profiles; i++) { vendor = sr_vendor_alias(hw_info->manufacturer); if (g_ascii_strcasecmp(vendor, pps_profiles[i].vendor)) continue; model_re = g_regex_new(pps_profiles[i].model, 0, 0, NULL); if (g_regex_match(model_re, hw_info->model, 0, &model_mi)) device = &pps_profiles[i]; g_match_info_unref(model_mi); g_regex_unref(model_re); if (device) break; } if (!device) { sr_scpi_hw_info_free(hw_info); return NULL; } sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; sdi->vendor = g_strdup(vendor); sdi->model = g_strdup(hw_info->model); sdi->version = g_strdup(hw_info->firmware_version); sdi->conn = scpi; sdi->driver = &scpi_pps_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->device = device; sdi->priv = devc; if (device->num_channels) { /* Static channels and groups. */ channels = (struct channel_spec *)device->channels; num_channels = device->num_channels; channel_groups = (struct channel_group_spec *)device->channel_groups; num_channel_groups = device->num_channel_groups; } else { /* Channels and groups need to be probed. */ ret = device->probe_channels(sdi, hw_info, &channels, &num_channels, &channel_groups, &num_channel_groups); if (ret != SR_OK) { sr_err("Failed to probe for channels."); return NULL; } /* * Since these were dynamically allocated, we'll need to free them * later. */ devc->channels = channels; devc->channel_groups = channel_groups; } ch_idx = 0; for (ch_num = 0; ch_num < num_channels; ch_num++) { /* Create one channel per measurable output unit. */ for (i = 0; i < ARRAY_SIZE(pci); i++) { if (!scpi_cmd_get(devc->device->commands, pci[i].command)) continue; g_snprintf(ch_name, 16, "%s%s", pci[i].prefix, channels[ch_num].name); ch = sr_channel_new(sdi, ch_idx++, SR_CHANNEL_ANALOG, TRUE, ch_name); pch = g_malloc0(sizeof(struct pps_channel)); pch->hw_output_idx = ch_num; pch->hwname = channels[ch_num].name; pch->mq = pci[i].mq; ch->priv = pch; } } for (i = 0; i < num_channel_groups; i++) { cgs = &channel_groups[i]; cg = g_malloc0(sizeof(struct sr_channel_group)); cg->name = g_strdup(cgs->name); for (j = 0, mask = 1; j < 64; j++, mask <<= 1) { if (cgs->channel_index_mask & mask) { for (l = sdi->channels; l; l = l->next) { ch = l->data; pch = ch->priv; if (pch->hw_output_idx == j) cg->channels = g_slist_append(cg->channels, ch); } } } pcg = g_malloc0(sizeof(struct pps_channel_group)); pcg->features = cgs->features; cg->priv = pcg; sdi->channel_groups = g_slist_append(sdi->channel_groups, cg); } sr_scpi_hw_info_free(hw_info); hw_info = NULL; scpi_cmd(sdi, devc->device->commands, SCPI_CMD_LOCAL); sr_scpi_close(scpi); return sdi; }
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; }