static int set_mq_volt(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
- const char *cmd;
-
if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC &&
(flags & SR_MQFLAG_DC) != SR_MQFLAG_DC)
return SR_ERR_NA;
- if ((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC)
- cmd = "F2";
- else
- cmd = "F1";
-
- return sr_scpi_send(scpi, "%s", cmd);
+ return sr_scpi_send(scpi, "%s",
+ ((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC) ? "F2" : "F1");
}
static int set_mq_amp(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
- const char *cmd;
-
if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC &&
(flags & SR_MQFLAG_DC) != SR_MQFLAG_DC)
return SR_ERR_NA;
- if (flags & SR_MQFLAG_AC)
- cmd = "F6";
- else
- cmd = "F5";
-
- return sr_scpi_send(scpi, "%s", cmd);
+ return sr_scpi_send(scpi, "%s", (flags & SR_MQFLAG_AC) ? "F6" : "F5");
}
static int set_mq_ohm(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
- const char *cmd;
-
- if (flags & SR_MQFLAG_FOUR_WIRE)
- cmd = "F4";
- else
- cmd = "F3";
-
- return sr_scpi_send(scpi, "%s", cmd);
+ return sr_scpi_send(scpi, "%s",
+ (flags & SR_MQFLAG_FOUR_WIRE) ? "F4" : "F3");
}
SR_PRIV int hp_3478a_set_mq(const struct sr_dev_inst *sdi, enum sr_mq mq,
static int parse_range_vdc(struct dev_context *devc, uint8_t range_byte)
{
- if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_30MV) {
+ if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_30MV)
devc->enc_digits = devc->spec_digits - 2;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_300MV) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_300MV)
devc->enc_digits = devc->spec_digits - 3;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_3V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_3V)
devc->enc_digits = devc->spec_digits - 1;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_30V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_30V)
devc->enc_digits = devc->spec_digits - 2;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_300V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VDC_300V)
devc->enc_digits = devc->spec_digits - 3;
- } else {
+ else
return SR_ERR_DATA;
- }
return SR_OK;
}
static int parse_range_vac(struct dev_context *devc, uint8_t range_byte)
{
- if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_300MV) {
+ if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_300MV)
devc->enc_digits = devc->spec_digits - 3;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_3V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_3V)
devc->enc_digits = devc->spec_digits - 1;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_30V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_30V)
devc->enc_digits = devc->spec_digits - 2;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_300V) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_VAC_300V)
devc->enc_digits = devc->spec_digits - 3;
- } else {
+ else
return SR_ERR_DATA;
- }
return SR_OK;
}
static int parse_range_a(struct dev_context *devc, uint8_t range_byte)
{
- if ((range_byte & SB1_RANGE_BLOCK) == RANGE_A_300MA) {
+ if ((range_byte & SB1_RANGE_BLOCK) == RANGE_A_300MA)
devc->enc_digits = devc->spec_digits - 3;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_A_3A) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_A_3A)
devc->enc_digits = devc->spec_digits - 1;
- } else {
+ else
return SR_ERR_DATA;
- }
return SR_OK;
}
static int parse_range_ohm(struct dev_context *devc, uint8_t range_byte)
{
- if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30R) {
+ if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30R)
devc->enc_digits = devc->spec_digits - 2;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_300R) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_300R)
devc->enc_digits = devc->spec_digits - 3;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_3KR) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_3KR)
devc->enc_digits = devc->spec_digits - 1;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30KR) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30KR)
devc->enc_digits = devc->spec_digits - 2;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_300KR) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_300KR)
devc->enc_digits = devc->spec_digits - 3;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_3MR) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_3MR)
devc->enc_digits = devc->spec_digits - 1;
- } else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30MR) {
+ else if ((range_byte & SB1_RANGE_BLOCK) == RANGE_OHM_30MR)
devc->enc_digits = devc->spec_digits - 2;
- } else {
+ else
return SR_ERR_DATA;
- }
return SR_OK;
}
static int parse_function_byte(struct dev_context *devc, uint8_t function_byte)
{
- devc->measurement_mq_flags = 0;
+ /* Digits / Resolution (spec_digits must be set before range parsing) */
+ if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_5_5)
+ devc->spec_digits = 6;
+ else if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_4_5)
+ devc->spec_digits = 5;
+ else if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_3_5)
+ devc->spec_digits = 4;
+ else
+ return SR_ERR_DATA;
/* Function + Range */
+ devc->measurement_mq_flags = 0;
if ((function_byte & SB1_FUNCTION_BLOCK) == FUNCTION_VDC) {
devc->measurement_mq = SR_MQ_VOLTAGE;
devc->measurement_mq_flags |= SR_MQFLAG_DC;
parse_range_ohm(devc, function_byte);
}
- /* Digits / Resolution */
- if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_5_5) {
- devc->spec_digits = 5;
- } else if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_4_5) {
- devc->spec_digits = 4;
- } else if ((function_byte & SB1_DIGITS_BLOCK) == DIGITS_3_5) {
- devc->spec_digits = 3;
- }
-
return SR_OK;
}
/* PON SRQ */
if ((sqr_byte & SRQ_POWER_ON) == SRQ_POWER_ON)
- sr_spew("hp_3478a_get_status_bytes: Power On SRQ or clear "
- "msg received");
+ sr_spew("Power On SRQ or clear msg received");
/* Cal failed SRQ */
if ((sqr_byte & SRQ_CAL_FAILED) == SRQ_CAL_FAILED)
- sr_spew("hp_3478a_get_status_bytes: CAL failed SRQ");
+ sr_spew("CAL failed SRQ");
/* Keyboard SRQ */
if ((sqr_byte & SRQ_KEYBORD) == SRQ_KEYBORD)
- sr_spew("hp_3478a_get_status_bytes: Keyboard SRQ");
+ sr_spew("Keyboard SRQ");
/* Hardware error SRQ */
if ((sqr_byte & SRQ_HARDWARE_ERR) == SRQ_HARDWARE_ERR)
- sr_spew("hp_3478a_get_status_bytes: Hardware error SRQ");
+ sr_spew("Hardware error SRQ");
/* Syntax error SRQ */
if ((sqr_byte & SRQ_SYNTAX_ERR) == SRQ_SYNTAX_ERR)
- sr_spew("hp_3478a_get_status_bytes: Syntax error SRQ");
+ sr_spew("Syntax error SRQ");
/* Every reading is available to the bus SRQ */
if ((sqr_byte & SRQ_BUS_AVAIL) == SRQ_BUS_AVAIL)
- sr_spew("hp_3478a_get_status_bytes: Every reading is available to "
- "the bus SRQ");
+ sr_spew("Every reading is available to the bus SRQ");
#endif
return SR_OK;
/* A/D link */
if ((error_byte & ERROR_AD_LINK) == ERROR_AD_LINK) {
- sr_err("hp_3478a: Failure in the A/D link");
+ sr_err("Failure in the A/D link");
ret = SR_ERR;
}
/* A/D Self Test */
if ((error_byte & ERROR_AD_SELF_TEST) == ERROR_AD_SELF_TEST) {
- sr_err("hp_3478a: A/D has failed its internal Self Test");
+ sr_err("A/D has failed its internal Self Test");
ret = SR_ERR;
}
/* A/D slope error */
if ((error_byte & ERROR_AD_SLOPE) == ERROR_AD_SLOPE) {
- sr_err("hp_3478a: There has been an A/D slope error");
+ sr_err("There has been an A/D slope error");
ret = SR_ERR;
}
/* ROM Selt Test */
if ((error_byte & ERROR_ROM_SELF_TEST) == ERROR_ROM_SELF_TEST) {
- sr_err("hp_3478a: The ROM Self Test has failed");
+ sr_err("The ROM Self Test has failed");
ret = SR_ERR;
}
/* RAM Selt Test */
if ((error_byte & ERROR_RAM_SELF_TEST) == ERROR_RAM_SELF_TEST) {
- sr_err("hp_3478a: The RAM Self Test has failed");
+ sr_err("The RAM Self Test has failed");
ret = SR_ERR;
}
/* Selt Test */
if ((error_byte & ERROR_SELF_TEST) == ERROR_SELF_TEST) {
- sr_err("hp_3478a: Self Test: Any of the CAL RAM locations have bad "
- "checksums, or a range with a bad checksum is selected");
+ sr_err("Self Test: Any of the CAL RAM locations have bad "
+ "checksums, or a range with a bad checksum is selected");
ret = SR_ERR;
}