scpi-pps: Use regex to match model names.
This commit is contained in:
parent
22c18b0370
commit
58b77c41ff
|
@ -45,6 +45,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
const struct scpi_pps *device;
|
const struct scpi_pps *device;
|
||||||
const struct channel_group_spec *cgs;
|
const struct channel_group_spec *cgs;
|
||||||
struct pps_channel_group *pcg;
|
struct pps_channel_group *pcg;
|
||||||
|
GRegex *model_re;
|
||||||
|
GMatchInfo *model_mi;
|
||||||
uint64_t mask;
|
uint64_t mask;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
const char *vendor;
|
const char *vendor;
|
||||||
|
@ -57,20 +59,23 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
device = NULL;
|
device = NULL;
|
||||||
for (i = 0; i < num_pps_profiles; i++) {
|
for (i = 0; i < num_pps_profiles; i++) {
|
||||||
vendor = get_vendor(hw_info->manufacturer);
|
vendor = get_vendor(hw_info->manufacturer);
|
||||||
if (strcasecmp(vendor, pps_profiles[i].idn_vendor))
|
if (strcasecmp(vendor, pps_profiles[i].vendor))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(hw_info->model, pps_profiles[i].idn_model)) {
|
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];
|
device = &pps_profiles[i];
|
||||||
|
g_match_info_unref(model_mi);
|
||||||
|
g_regex_unref(model_re);
|
||||||
|
if (device)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!device) {
|
if (!device) {
|
||||||
sr_scpi_hw_info_free(hw_info);
|
sr_scpi_hw_info_free(hw_info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, vendor,
|
sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, vendor, hw_info->model,
|
||||||
device->idn_model, hw_info->firmware_version);
|
hw_info->firmware_version);
|
||||||
sdi->conn = scpi;
|
sdi->conn = scpi;
|
||||||
sdi->driver = di;
|
sdi->driver = di;
|
||||||
sdi->inst_type = SR_INST_SCPI;
|
sdi->inst_type = SR_INST_SCPI;
|
||||||
|
|
|
@ -70,8 +70,8 @@ enum pps_features {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scpi_pps {
|
struct scpi_pps {
|
||||||
char *idn_vendor;
|
char *vendor;
|
||||||
char *idn_model;
|
char *model;
|
||||||
uint64_t features;
|
uint64_t features;
|
||||||
const int32_t *devopts;
|
const int32_t *devopts;
|
||||||
unsigned int num_devopts;
|
unsigned int num_devopts;
|
||||||
|
|
Loading…
Reference in New Issue