When the channel state is retrieved, query the pre-set byteorder for
SCPI data blocks as well. When samples get retrieved during capture,
support float representations in either big or little endian format.
This commit unbreaks devices which operate in BE format by default
(tested with HMO2524). It keeps working with LE format as before. For
devices which don't support the byteorder query or return unknown
responses, LE format is assumed for backwards compatibility. The
device's byteorder is only queried and never set. This makes the
commit least intrusive.
[SCPI_CMD_GET_ANALOG_CHAN_STATE] = ":CHAN%d:STAT?",
[SCPI_CMD_SET_ANALOG_CHAN_STATE] = ":CHAN%d:STAT %d",
[SCPI_CMD_GET_PROBE_UNIT] = ":PROB%d:SET:ATT:UNIT?",
[SCPI_CMD_GET_ANALOG_CHAN_STATE] = ":CHAN%d:STAT?",
[SCPI_CMD_SET_ANALOG_CHAN_STATE] = ":CHAN%d:STAT %d",
[SCPI_CMD_GET_PROBE_UNIT] = ":PROB%d:SET:ATT:UNIT?",
+ [SCPI_CMD_GET_BYTE_ORDER] = ":FORM:BORD?",
};
static const uint32_t hmo_devopts[] = {
};
static const uint32_t hmo_devopts[] = {
+ /*
+ * Determine the byte order which will be used for data blocks.
+ * A ":FORM:BORD?" request will yield either an "MSBF" or "LSBF"
+ * response.
+ */
+ state->byteorder = '?';
+ if (sr_scpi_get_string(scpi,
+ (*config->scpi_dialect)[SCPI_CMD_GET_BYTE_ORDER],
+ &tmp_str) != SR_OK)
+ return SR_ERR;
+ if (tmp_str[0] == 'M')
+ state->byteorder = 'b';
+ else if (tmp_str[0] == 'L')
+ state->byteorder = 'l';
+ g_free(tmp_str);
+
encoding.unitsize = sizeof(float);
encoding.is_signed = TRUE;
encoding.is_float = TRUE;
encoding.unitsize = sizeof(float);
encoding.is_signed = TRUE;
encoding.is_float = TRUE;
- encoding.is_bigendian = FALSE;
+ /* Assume LE format when unknown for backwards compat. */
+ encoding.is_bigendian = (state->byteorder == 'b') ? TRUE : FALSE;
/* TODO: Use proper 'digits' value for this device (and its modes). */
encoding.digits = 2;
encoding.is_digits_decimal = FALSE;
/* TODO: Use proper 'digits' value for this device (and its modes). */
encoding.digits = 2;
encoding.is_digits_decimal = FALSE;
int trigger_source;
int trigger_slope;
uint64_t sample_rate;
int trigger_source;
int trigger_slope;
uint64_t sample_rate;
+
+ /** SCPI data block byte order. 'l'/'b' when known, '?' otherwise. */
+ char byteorder;
};
/** Private, per-device-instance driver context. */
};
/** Private, per-device-instance driver context. */
SCPI_CMD_SET_PROBE_UNIT,
SCPI_CMD_GET_ANALOG_CHAN_NAME,
SCPI_CMD_GET_DIG_CHAN_NAME,
SCPI_CMD_SET_PROBE_UNIT,
SCPI_CMD_GET_ANALOG_CHAN_NAME,
SCPI_CMD_GET_DIG_CHAN_NAME,
+ SCPI_CMD_GET_BYTE_ORDER,