The Probe Unit Enquiry command is not officially documented in the SCPI Programmers Manual, therefore, although this might just be a documentation error, there is some risk that some ancient firmware versions do not support such enquiry. Fortunately the Probe Unit Setup command is always documented therefore it should be supported by all firmware versions, so we fall back to setting up Volts unit instead of aborting, if such enquiry fails.
This patch might fix the following problem: https://sourceforge.net/p/sigrok/mailman/message/36442494/ [sigrok-devel] Hameg HMO2524 - scpi: Timed out waiting for SCPI response. posted: 2018-10-16 13:53:21 Signed-off-by: Guido Trentalancia <gu...@trentalancia.com> --- src/hardware/hameg-hmo/protocol.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff -pru libsigrok-git-20102018-orig/src/hardware/hameg-hmo/protocol.c libsigrok-git-20102018-hameg-hmo-fix-missing-probe-unit-enquiry-cmd/src/hardware/hameg-hmo/protocol.c --- libsigrok-git-20102018-orig/src/hardware/hameg-hmo/protocol.c 2018-10-20 13:12:30.895966966 +0200 +++ libsigrok-git-20102018-hameg-hmo-fix-missing-probe-unit-enquiry-cmd/src/hardware/hameg-hmo/protocol.c 2018-11-03 19:38:16.547245847 +0100 @@ -55,6 +55,7 @@ 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_SET_PROBE_UNIT] = ":PROB%d:SET:ATT:UNIT %s", }; static const uint32_t devopts[] = { @@ -453,14 +454,29 @@ static int analog_channel_state_get(stru (*config->scpi_dialect)[SCPI_CMD_GET_PROBE_UNIT], i + 1); - if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK) - return SR_ERR; + /* The Probe Unit Enquiry command is not officially documented in the SCPI + * Programmers Manual, therefore, although this might just be a documentation + * error, there is some risk that some ancient firmware versions do not support + * such enquiry. Fortunately the Probe Unit Setup command is always documented + * therefore it should be supported by all firmware versions, so we fall back + * to setting up Volts unit instead of aborting, if such enquiry fails. + */ + if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK) { + g_snprintf(command, sizeof(command), + (*config->scpi_dialect)[SCPI_CMD_SET_PROBE_UNIT], + i + 1, "V"); + + if (sr_scpi_send(scpi, command) != SR_OK) + return SR_ERR; - if (tmp_str[0] == 'A') - state->analog_channels[i].probe_unit = 'A'; - else state->analog_channels[i].probe_unit = 'V'; - g_free(tmp_str); + } else { + if (tmp_str[0] == 'A') + state->analog_channels[i].probe_unit = 'A'; + else + state->analog_channels[i].probe_unit = 'V'; + g_free(tmp_str); + } } return SR_OK; _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel