rohde-schwarz-sme-0x: Minor whitespace and consistency fixes.

This commit is contained in:
Uwe Hermann 2017-03-02 14:23:07 +01:00
parent 9e50659470
commit ed1fae0bb3
2 changed files with 37 additions and 43 deletions

View File

@ -34,35 +34,35 @@ static const struct rs_device_model device_models[] = {
.freq_max = SR_GHZ(1.5), .freq_max = SR_GHZ(1.5),
.freq_min = SR_KHZ(5), .freq_min = SR_KHZ(5),
.power_max = 16, .power_max = 16,
.power_min = -144 .power_min = -144,
}, },
{ {
.model_str = "SME03E", .model_str = "SME03E",
.freq_max = SR_GHZ(2.2), .freq_max = SR_GHZ(2.2),
.freq_min = SR_KHZ(5), .freq_min = SR_KHZ(5),
.power_max = 16, .power_max = 16,
.power_min = -144 .power_min = -144,
}, },
{ {
.model_str = "SME03A", .model_str = "SME03A",
.freq_max = SR_GHZ(3), .freq_max = SR_GHZ(3),
.freq_min = SR_KHZ(5), .freq_min = SR_KHZ(5),
.power_max = 16, .power_max = 16,
.power_min = -144 .power_min = -144,
}, },
{ {
.model_str = "SME03", .model_str = "SME03",
.freq_max = SR_GHZ(3), .freq_max = SR_GHZ(3),
.freq_min = SR_KHZ(5), .freq_min = SR_KHZ(5),
.power_max = 16, .power_max = 16,
.power_min = -144 .power_min = -144,
}, },
{ {
.model_str = "SME06", .model_str = "SME06",
.freq_max = SR_GHZ(1.5), .freq_max = SR_GHZ(1.5),
.freq_min = SR_KHZ(5), .freq_min = SR_KHZ(5),
.power_max = 16, .power_max = 16,
.power_min = -144 .power_min = -144,
} }
}; };
@ -93,7 +93,8 @@ static int rs_init_device(struct sr_dev_inst *sdi)
} }
if (!model_found) { if (!model_found) {
sr_dbg("Device %s %s is not supported by this driver", manufacturer, sdi->model); sr_dbg("Device %s %s is not supported by this driver.",
manufacturer, sdi->model);
return SR_ERR_NA; return SR_ERR_NA;
} }
@ -112,13 +113,11 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
rs_sme0x_mode_remote(scpi); rs_sme0x_mode_remote(scpi);
if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK)
goto fail; goto fail;
}
if (strcmp(hw_info->manufacturer, manufacturer) != 0) { if (strcmp(hw_info->manufacturer, manufacturer) != 0)
goto fail; goto fail;
}
sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi = g_malloc0(sizeof(struct sr_dev_inst));
sdi->vendor = g_strdup(hw_info->manufacturer); sdi->vendor = g_strdup(hw_info->manufacturer);
@ -135,20 +134,17 @@ static struct sr_dev_inst *rs_probe_serial_device(struct sr_scpi_dev_inst *scpi)
devc = g_malloc0(sizeof(struct dev_context)); devc = g_malloc0(sizeof(struct dev_context));
sdi->priv = devc; sdi->priv = devc;
if (rs_init_device(sdi) != SR_OK) { if (rs_init_device(sdi) != SR_OK)
goto fail; goto fail;
}
return sdi; return sdi;
fail: fail:
if (hw_info) { if (hw_info)
sr_scpi_hw_info_free(hw_info); sr_scpi_hw_info_free(hw_info);
}
if (sdi) { if (sdi)
sr_dev_inst_free(sdi); sr_dev_inst_free(sdi);
}
g_free(devc); g_free(devc);
return NULL; return NULL;
@ -166,9 +162,8 @@ static int dev_clear(const struct sr_dev_driver *di)
static int dev_open(struct sr_dev_inst *sdi) static int dev_open(struct sr_dev_inst *sdi)
{ {
if ((sdi->status != SR_ST_ACTIVE) && (sr_scpi_open(sdi->conn) != SR_OK)) { if ((sdi->status != SR_ST_ACTIVE) && (sr_scpi_open(sdi->conn) != SR_OK))
return SR_ERR; return SR_ERR;
}
sdi->status = SR_ST_ACTIVE; sdi->status = SR_ST_ACTIVE;
@ -177,9 +172,8 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
if (sdi->status == SR_ST_INACTIVE) { if (sdi->status == SR_ST_INACTIVE)
return SR_OK; return SR_OK;
}
sr_scpi_close(sdi->conn); sr_scpi_close(sdi->conn);
@ -218,13 +212,11 @@ static int config_set(uint32_t key, GVariant *data,
(void)cg; (void)cg;
if (!sdi) { if (!sdi)
return SR_ERR_ARG; return SR_ERR_ARG;
}
if (sdi->status != SR_ST_ACTIVE) { if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
}
switch (key) { switch (key) {
case SR_CONF_OUTPUT_FREQUENCY: case SR_CONF_OUTPUT_FREQUENCY:
@ -250,10 +242,12 @@ static int config_list(uint32_t key, GVariant **data,
switch (key) { switch (key) {
case SR_CONF_SCAN_OPTIONS: case SR_CONF_SCAN_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
break; break;
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
break; break;
default: default:
return SR_ERR_NA; return SR_ERR_NA;
@ -264,9 +258,8 @@ static int config_list(uint32_t key, GVariant **data,
static int dev_acquisition_start(const struct sr_dev_inst *sdi) static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{ {
if (sdi->status != SR_ST_ACTIVE) { if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
}
return SR_OK; return SR_OK;
} }

View File

@ -28,7 +28,7 @@ enum {
RS_CMD_SET_FREQ, RS_CMD_SET_FREQ,
RS_CMD_SET_POWER, RS_CMD_SET_POWER,
RS_CMD_GET_FREQ, RS_CMD_GET_FREQ,
RS_CMD_GET_POWER RS_CMD_GET_POWER,
}; };
static char *commands[] = { static char *commands[] = {
@ -36,53 +36,54 @@ static char *commands[] = {
[RS_CMD_SET_FREQ] = "FREQ %.1fHz", [RS_CMD_SET_FREQ] = "FREQ %.1fHz",
[RS_CMD_SET_POWER] = "POW %.1fdBm", [RS_CMD_SET_POWER] = "POW %.1fdBm",
[RS_CMD_GET_FREQ] = "FREQ?", [RS_CMD_GET_FREQ] = "FREQ?",
[RS_CMD_GET_POWER] = "POW?" [RS_CMD_GET_POWER] = "POW?",
}; };
SR_PRIV int rs_sme0x_mode_remote(struct sr_scpi_dev_inst *scpi) { SR_PRIV int rs_sme0x_mode_remote(struct sr_scpi_dev_inst *scpi)
{
return sr_scpi_send(scpi, commands[RS_CMD_CONTROL_REMOTE]); return sr_scpi_send(scpi, commands[RS_CMD_CONTROL_REMOTE]);
} }
SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double *freq) { SR_PRIV int rs_sme0x_get_freq(const struct sr_dev_inst *sdi, double *freq)
if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_FREQ], freq) != SR_OK) { {
if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_FREQ], freq) != SR_OK)
return SR_ERR; return SR_ERR;
}
return SR_OK; return SR_OK;
} }
SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double *power) { SR_PRIV int rs_sme0x_get_power(const struct sr_dev_inst *sdi, double *power)
if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_POWER], power) != SR_OK) { {
if (sr_scpi_get_double(sdi->conn, commands[RS_CMD_GET_POWER], power) != SR_OK)
return SR_ERR; return SR_ERR;
}
return SR_OK; return SR_OK;
} }
SR_PRIV int rs_sme0x_set_freq(const struct sr_dev_inst *sdi, double freq) { SR_PRIV int rs_sme0x_set_freq(const struct sr_dev_inst *sdi, double freq)
{
struct dev_context *devc; struct dev_context *devc;
const struct rs_device_model *config; const struct rs_device_model *config;
devc = sdi->priv; devc = sdi->priv;
config = devc->model_config; config = devc->model_config;
if ((freq > config->freq_max) || (freq < config->freq_min)) { if ((freq > config->freq_max) || (freq < config->freq_min))
return SR_ERR_ARG; return SR_ERR_ARG;
}
return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_FREQ], freq); return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_FREQ], freq);
} }
SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power) { SR_PRIV int rs_sme0x_set_power(const struct sr_dev_inst *sdi, double power)
{
struct dev_context *devc; struct dev_context *devc;
const struct rs_device_model *config; const struct rs_device_model *config;
devc = sdi->priv; devc = sdi->priv;
config = devc->model_config; config = devc->model_config;
if ((power > config->power_max) || (power < config->power_min)) { if ((power > config->power_max) || (power < config->power_min))
return SR_ERR_ARG; return SR_ERR_ARG;
}
return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_POWER], power); return sr_scpi_send(sdi->conn, commands[RS_CMD_SET_POWER], power);
} }