X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fscpi-pps%2Fapi.c;h=31e7ca6cf418388f0b6c7293c0ccbc808d2124c1;hb=58b77c41ff815d0157c58d052dfed9b087db42d8;hp=ec84db74eabf856bcb6224bde03782a744bf937f;hpb=9e45cd41fd1618238c8a3afc56d4031c984bc3c5;p=libsigrok.git diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index ec84db74..31e7ca6c 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -22,8 +22,8 @@ SR_PRIV struct sr_dev_driver scpi_pps_driver_info; static struct sr_dev_driver *di = &scpi_pps_driver_info; -SR_PRIV const struct scpi_pps pps_profiles[] = {}; -unsigned int num_pps_profiles; +extern unsigned int num_pps_profiles; +extern const struct scpi_pps pps_profiles[]; static const int32_t scanopts[] = { SR_CONF_CONN, @@ -45,8 +45,11 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) const struct scpi_pps *device; const struct channel_group_spec *cgs; struct pps_channel_group *pcg; + GRegex *model_re; + GMatchInfo *model_mi; uint64_t mask; unsigned int i, j; + const char *vendor; if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response."); @@ -55,18 +58,23 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) device = NULL; for (i = 0; i < num_pps_profiles; i++) { - if (!strcasecmp(hw_info->manufacturer, pps_profiles[i].idn_vendor) && - !strcmp(hw_info->model, pps_profiles[i].idn_model)) { + vendor = get_vendor(hw_info->manufacturer); + if (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 = sr_dev_inst_new(0, SR_ST_ACTIVE, device->vendor, device->idn_model, + sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, vendor, hw_info->model, hw_info->firmware_version); sdi->conn = scpi; sdi->driver = di;