Support the official SCPI command set for single POD devices. The official SCPI command set does not specify to use a POD index for SCPI commands related to the logical POD when only one POD is available on the device.
Simply follow the specifications for the hameg-hmo driver. Signed-off-by: Guido Trentalancia <gu...@trentalancia.com> --- src/hardware/hameg-hmo/api.c | 2 ++ src/hardware/hameg-hmo/protocol.c | 29 ++++++++++++++++++++++++++++- src/hardware/hameg-hmo/protocol.h | 2 ++ 3 files changed, 32 insertions(+), 1 deletion(-) diff -pru libsigrok-git-orig/src/hardware/hameg-hmo/api.c libsigrok-git-single-pod/src/hardware/hameg-hmo/api.c --- libsigrok-git-orig/src/hardware/hameg-hmo/api.c 2018-11-12 20:17:20.002238702 +0100 +++ libsigrok-git-single-pod/src/hardware/hameg-hmo/api.c 2018-11-12 23:55:10.370154076 +0100 @@ -522,6 +522,8 @@ SR_PRIV int hmo_request_data(const struc g_snprintf(command, sizeof(command), (*model->scpi_dialect)[SCPI_CMD_GET_DIG_DATA], ch->index < 8 ? 1 : 2); + if (model->digital_pods == 1) + hmo_single_pod_transform_cmd(command); break; default: sr_err("Invalid channel type."); diff -pru libsigrok-git-orig/src/hardware/hameg-hmo/protocol.c libsigrok-git-single-pod/src/hardware/hameg-hmo/protocol.c --- libsigrok-git-orig/src/hardware/hameg-hmo/protocol.c 2018-11-12 20:17:20.003238702 +0100 +++ libsigrok-git-single-pod/src/hardware/hameg-hmo/protocol.c 2018-11-13 00:02:04.009507198 +0100 @@ -374,6 +374,24 @@ static const struct scope_config scope_m }, }; +/* Transform a generic dual-pods SCPI command to a single-pod device, + * in order to follow the SCPI Programmers Manual. + */ +SR_PRIV void hmo_single_pod_transform_cmd(char *command) +{ + int len, len_end; + gchar *command_end; + + len = strlen(command); + len_end = strlen(strstr(command, ":POD")); + + command_end = g_strdup(&command[len - len_end + 5]); + + g_strlcpy(&command[len - len_end + 4], command_end, len_end - 1); + + g_free(command_end); +} + static void scope_state_dump(const struct scope_config *config, struct scope_state *state) { @@ -602,6 +620,8 @@ static int digital_channel_state_get(str g_snprintf(command, sizeof(command), (*config->scpi_dialect)[SCPI_CMD_GET_DIG_POD_STATE], i + 1); + if (config->digital_pods == 1) + hmo_single_pod_transform_cmd(command); if (sr_scpi_get_bool(scpi, command, &state->digital_pods[i].state) != SR_OK) @@ -611,6 +631,9 @@ static int digital_channel_state_get(str (*config->scpi_dialect)[SCPI_CMD_GET_DIG_POD_THRESHOLD], i + 1); + if (config->digital_pods == 1) + hmo_single_pod_transform_cmd(command); + if (scope_state_get_array_option(scpi, command, config->logic_threshold, config->num_logic_threshold, &state->digital_pods[i].threshold) != SR_OK) @@ -627,10 +650,14 @@ static int digital_channel_state_get(str i + 1, 2); // USER2 for custom logic_threshold setting if (!strcmp("USER1", (*config->logic_threshold)[state->digital_pods[i].threshold]) || - !strcmp("USER2", (*config->logic_threshold)[state->digital_pods[i].threshold])) + !strcmp("USER2", (*config->logic_threshold)[state->digital_pods[i].threshold])) { + if (config->digital_pods == 1) + hmo_single_pod_transform_cmd(command); + if (sr_scpi_get_float(scpi, command, &state->digital_pods[i].user_threshold) != SR_OK) return SR_ERR; + } } return SR_OK; diff -pru libsigrok-git-orig/src/hardware/hameg-hmo/protocol.h libsigrok-git-single-pod/src/hardware/hameg-hmo/protocol.h --- libsigrok-git-orig/src/hardware/hameg-hmo/protocol.h 2018-11-12 20:17:20.010238702 +0100 +++ libsigrok-git-single-pod/src/hardware/hameg-hmo/protocol.h 2018-11-12 23:54:24.776155701 +0100 @@ -125,6 +125,8 @@ struct dev_context { GByteArray *logic_data; }; +SR_PRIV void hmo_single_pod_transform_cmd(char *command); + SR_PRIV int hmo_init_device(struct sr_dev_inst *sdi); SR_PRIV int hmo_request_data(const struct sr_dev_inst *sdi); SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data); _______________________________________________ sigrok-devel mailing list sigrok-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sigrok-devel