serial = sdi->conn;
va_start(args, cmd);
- vsnprintf(buf, sizeof(buf)-3, cmd, args);
+ vsnprintf(buf, sizeof(buf) - 3, cmd, args);
va_end(args);
sr_spew("Sending '%s'.", buf);
if (!strncmp(buf, "*IDN?", 5))
s = g_match_info_fetch(match, 1);
sr_spew("STAT response '%s'.", s);
+ /* dBm/dBV modes. */
+ if ((s[2] & ~0x20) == 'M')
+ devc->mode_dbm_dbv = devc->cur_unit[0] = SR_UNIT_DECIBEL_MW;
+ else if ((s[2] & ~0x20) == 'V')
+ devc->mode_dbm_dbv = devc->cur_unit[0] = SR_UNIT_DECIBEL_VOLT;
+ else
+ devc->mode_dbm_dbv = 0;
+
/* Peak hold mode. */
if (s[4] == '1')
devc->cur_mqflags[0] |= SR_MQFLAG_MAX;
else
devc->cur_mqflags[0] &= ~(SR_MQFLAG_MAX | SR_MQFLAG_MIN | SR_MQFLAG_AVG);
+ /* dBm/dBV modes. */
+ if ((s[2] & ~0x20) == 'M')
+ devc->mode_dbm_dbv = devc->cur_unit[0] = SR_UNIT_DECIBEL_MW;
+ else if ((s[2] & ~0x20) == 'V')
+ devc->mode_dbm_dbv = devc->cur_unit[0] = SR_UNIT_DECIBEL_VOLT;
+ else
+ devc->mode_dbm_dbv = 0;
+
/* Peak hold mode. */
if (s[4] == '4')
devc->cur_mqflags[0] |= SR_MQFLAG_MAX;
float fvalue;
const char *s;
char *mstr;
- int i;
+ int i, exp;
sr_spew("FETC reply '%s'.", g_match_info_get_string(match));
devc = sdi->priv;
fvalue *= powf(10, devc->cur_exponent[i]);
}
+ if (devc->cur_unit[i] == SR_UNIT_DECIBEL_MW ||
+ devc->cur_unit[i] == SR_UNIT_DECIBEL_VOLT ||
+ devc->cur_unit[i] == SR_UNIT_PERCENTAGE) {
+ mstr = g_match_info_fetch(match, 2);
+ if (mstr && sr_atoi(mstr, &exp) == SR_OK) {
+ devc->cur_digits[i] = MIN(4 - exp, devc->cur_digits[i]);
+ devc->cur_encoding[i] = MIN(5 - exp, devc->cur_encoding[i]);
+ }
+ g_free(mstr);
+ }
+
sr_analog_init(&analog, &encoding, &meaning, &spec,
devc->cur_digits[i] - devc->cur_exponent[i]);
analog.meaning->mq = devc->cur_mq[i];
devc->cur_unit[i] = SR_UNIT_VOLT;
devc->cur_mqflags[i] = 0;
devc->cur_exponent[i] = 0;
+ if (i == 0 && devc->mode_dbm_dbv) {
+ devc->cur_unit[i] = devc->mode_dbm_dbv;
+ devc->cur_digits[i] = 3;
+ devc->cur_encoding[i] = 4;
+ }
if (mstr[4] == ':') {
if (!strncmp(mstr + 5, "ACDC", 4)) {
/* AC + DC offset */
devc->cur_unit[i] = SR_UNIT_HERTZ;
devc->cur_mqflags[i] = 0;
devc->cur_exponent[i] = 0;
+ } else if (!strncmp(mstr, "PULS:PWID", 9)) {
+ devc->cur_mq[i] = SR_MQ_PULSE_WIDTH;
+ devc->cur_unit[i] = SR_UNIT_SECOND;
+ devc->cur_mqflags[i] = 0;
+ devc->cur_exponent[i] = 0;
+ devc->cur_encoding[i] = MIN(devc->cur_encoding[i], 6);
+ } else if (!strncmp(mstr, "PULS:PDUT", 9)) {
+ devc->cur_mq[i] = SR_MQ_DUTY_CYCLE;
+ devc->cur_unit[i] = SR_UNIT_PERCENTAGE;
+ devc->cur_mqflags[i] = 0;
+ devc->cur_exponent[i] = 0;
+ devc->cur_digits[i] = 3;
+ devc->cur_encoding[i] = 4;
} else if (!strcmp(mstr, "CONT")) {
devc->cur_mq[i] = SR_MQ_CONTINUITY;
- devc->cur_unit[i] = SR_UNIT_BOOLEAN;
+ devc->cur_unit[i] = SR_UNIT_OHM;
devc->cur_mqflags[i] = 0;
devc->cur_exponent[i] = 0;
} else if (!strcmp(mstr, "DIOD")) {
{ "^\"(\\d\\d.{18}\\d)\"$", recv_stat_u128x },
{ "^\\*([0-9])$", recv_switch },
{ "^([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))$", recv_fetc },
- { "^\"(VOLT|CURR|RES|COND|CAP|FREQ|FC1|FC100) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
+ { "^\"(VOLT|CURR|RES|CONT|COND|CAP|FREQ|FC1|FC100) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
{ "^\"(VOLT:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
{ "^\"(CURR:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
{ "^\"(FREQ:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
{ "^\"(CPER:[40]-20mA) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
+ { "^\"(PULS:PWID|PULS:PWID:[ACD]+) ([-+][0-9\\.E\\-+]+),([-+][0-9]\\.[0-9]{8}E([-+][0-9]{2}))\"$", recv_conf_u124x_5x },
{ "^\"(TEMP:[A-Z]+) ([A-Z]+)\"$", recv_conf_u124x_5x },
- { "^\"(DIOD|SQU|TEMP)\"$", recv_conf_u124x_5x },
+ { "^\"(DIOD|SQU|PULS:PDUT|TEMP)\"$", recv_conf_u124x_5x },
ALL_ZERO
};