From: Gerhard Sittig Date: Fri, 30 Dec 2016 22:46:27 +0000 (+0100) Subject: hameg-hmo: Use the host's endianess to read analog channel data via SCPI X-Git-Tag: libsigrok-0.5.0~146 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=65a6794ea1fef5064e7d47403a7bbbed76c3058b hameg-hmo: Use the host's endianess to read analog channel data via SCPI Configure the scope to the host's native endianess before downloading acquisition data from analog channels. This unbreaks operation on those models which default to a representation which differs from the host. --- diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 92f5ab67..ead97cd4 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -568,6 +568,11 @@ SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi) case SR_CHANNEL_ANALOG: g_snprintf(command, sizeof(command), (*model->scpi_dialect)[SCPI_CMD_GET_ANALOG_DATA], +#ifdef WORDS_BIGENDIAN + "MSBF", +#else + "LSBF", +#endif ch->index + 1); break; case SR_CHANNEL_LOGIC: diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index 528d7b04..97eb77aa 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -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?", @@ -821,7 +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; +#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; diff --git a/src/hardware/hameg-hmo/protocol.h b/src/hardware/hameg-hmo/protocol.h index 6219ed63..92c9b675 100644 --- a/src/hardware/hameg-hmo/protocol.h +++ b/src/hardware/hameg-hmo/protocol.h @@ -29,7 +29,7 @@ #define LOG_PREFIX "hameg-hmo" #define MAX_INSTRUMENT_VERSIONS 10 -#define MAX_COMMAND_SIZE 31 +#define MAX_COMMAND_SIZE 48 struct scope_config { const char *name[MAX_INSTRUMENT_VERSIONS];