scpi-pps: Generalize vendor name cleanup.
This commit is contained in:
parent
d4eabea847
commit
22c18b0370
|
@ -47,6 +47,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
struct pps_channel_group *pcg;
|
struct pps_channel_group *pcg;
|
||||||
uint64_t mask;
|
uint64_t mask;
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
const char *vendor;
|
||||||
|
|
||||||
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
|
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
|
||||||
sr_info("Couldn't get IDN response.");
|
sr_info("Couldn't get IDN response.");
|
||||||
|
@ -55,8 +56,10 @@ 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++) {
|
||||||
if (!strcasecmp(hw_info->manufacturer, pps_profiles[i].idn_vendor) &&
|
vendor = get_vendor(hw_info->manufacturer);
|
||||||
!strcmp(hw_info->model, pps_profiles[i].idn_model)) {
|
if (strcasecmp(vendor, pps_profiles[i].idn_vendor))
|
||||||
|
continue;
|
||||||
|
if (!strcmp(hw_info->model, pps_profiles[i].idn_model)) {
|
||||||
device = &pps_profiles[i];
|
device = &pps_profiles[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +69,8 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
return NULL;
|
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->firmware_version);
|
device->idn_model, 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;
|
||||||
|
|
|
@ -17,14 +17,27 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
#define CH_IDX(x) (1 << x)
|
#define CH_IDX(x) (1 << x)
|
||||||
|
|
||||||
enum vendors {
|
const char *pps_vendors[][2] = {
|
||||||
RIGOL,
|
{ "RIGOL TECHNOLOGIES", "Rigol" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *get_vendor(const char *raw_vendor)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(pps_vendors); i++) {
|
||||||
|
if (!strcasecmp(raw_vendor, pps_vendors[i][0]))
|
||||||
|
return pps_vendors[i][1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return raw_vendor;
|
||||||
|
}
|
||||||
|
|
||||||
/* Rigol DP800 series */
|
/* Rigol DP800 series */
|
||||||
static const int32_t devopts_rigol_dp800[] = {
|
static const int32_t devopts_rigol_dp800[] = {
|
||||||
SR_CONF_POWER_SUPPLY,
|
SR_CONF_POWER_SUPPLY,
|
||||||
|
@ -87,7 +100,7 @@ struct scpi_command cmd_rigol_dp800[] = {
|
||||||
|
|
||||||
SR_PRIV const struct scpi_pps pps_profiles[] = {
|
SR_PRIV const struct scpi_pps pps_profiles[] = {
|
||||||
/* Rigol DP800 series */
|
/* Rigol DP800 series */
|
||||||
{ RIGOL, "Rigol", "RIGOL TECHNOLOGIES", "DP832", PPS_OTP,
|
{ "Rigol", "DP832", PPS_OTP,
|
||||||
ARRAY_AND_SIZE(devopts_rigol_dp800),
|
ARRAY_AND_SIZE(devopts_rigol_dp800),
|
||||||
ARRAY_AND_SIZE(devopts_cg_rigol_dp800),
|
ARRAY_AND_SIZE(devopts_cg_rigol_dp800),
|
||||||
ARRAY_AND_SIZE(ch_rigol_dp800),
|
ARRAY_AND_SIZE(ch_rigol_dp800),
|
||||||
|
|
|
@ -70,8 +70,6 @@ enum pps_features {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scpi_pps {
|
struct scpi_pps {
|
||||||
int vendor_id;
|
|
||||||
char *vendor;
|
|
||||||
char *idn_vendor;
|
char *idn_vendor;
|
||||||
char *idn_model;
|
char *idn_model;
|
||||||
uint64_t features;
|
uint64_t features;
|
||||||
|
@ -130,6 +128,7 @@ struct dev_context {
|
||||||
struct sr_channel *cur_channel;
|
struct sr_channel *cur_channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *get_vendor(const char *raw_vendor);
|
||||||
SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...);
|
SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...);
|
||||||
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue