]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
hameg-hmo: Use the host's endianess to read analog channel data via SCPI
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 99a30acd75dd8ec21af14235be879732d87ea87b..97eb77aaac5ddce714e3d43ec1db41ad2767a790 100644 (file)
@@ -31,7 +31,8 @@ static const char *hameg_scpi_dialect[] = {
        [SCPI_CMD_SET_COUPLING]             = ":CHAN%d:COUP %s",
        [SCPI_CMD_GET_SAMPLE_RATE]          = ":ACQ:SRAT?",
        [SCPI_CMD_GET_SAMPLE_RATE_LIVE]     = ":%s:DATA:POINTS?",
-       [SCPI_CMD_GET_ANALOG_DATA]          = ":FORM REAL,32;:CHAN%d:DATA?",
+       [SCPI_CMD_GET_ANALOG_DATA]          = ":FORM:BORD %s;" \
+                                             ":FORM REAL,32;:CHAN%d:DATA?",
        [SCPI_CMD_GET_VERTICAL_DIV]         = ":CHAN%d:SCAL?",
        [SCPI_CMD_SET_VERTICAL_DIV]         = ":CHAN%d:SCAL %s",
        [SCPI_CMD_GET_DIG_POD_STATE]        = ":POD%d:STAT?",
@@ -48,7 +49,6 @@ static const char *hameg_scpi_dialect[] = {
        [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[] = {
@@ -496,22 +496,6 @@ static int analog_channel_state_get(struct sr_scpi_dev_inst *scpi,
                g_free(tmp_str);
        }
 
-       /*
-        * 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);
-
        return SR_OK;
 }
 
@@ -838,8 +822,11 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                encoding.unitsize = sizeof(float);
                encoding.is_signed = TRUE;
                encoding.is_float = TRUE;
-               /* Assume LE format when unknown for backwards compat. */
-               encoding.is_bigendian = (state->byteorder == 'b') ? TRUE : FALSE;
+#ifdef WORDS_BIGENDIAN
+               encoding.is_bigendian = TRUE;
+#else
+               encoding.is_bigendian = FALSE;
+#endif
                /* TODO: Use proper 'digits' value for this device (and its modes). */
                encoding.digits = 2;
                encoding.is_digits_decimal = FALSE;