X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fhelpers.c;h=dc19c3ab93f931af3e491dd77c1ecb53de1523c5;hb=050eb3b32d96a7c0a54dee9ae249514eff937d21;hp=d93d9e24851d2cc9822fd12e0bfcfdf20bc5c0c8;hpb=91ef511db2370904f8765a13e315fbddaf5ffe07;p=libsigrok.git
diff --git a/src/scpi/helpers.c b/src/scpi/helpers.c
index d93d9e24..dc19c3ab 100644
--- a/src/scpi/helpers.c
+++ b/src/scpi/helpers.c
@@ -17,6 +17,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include "libsigrok-internal.h"
@@ -38,7 +39,7 @@ SR_PRIV const char *sr_vendor_alias(const char *raw_vendor)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(scpi_vendors); i++) {
- if (!strcasecmp(raw_vendor, scpi_vendors[i][0]))
+ if (!g_ascii_strcasecmp(raw_vendor, scpi_vendors[i][0]))
return scpi_vendors[i][1];
}
@@ -54,7 +55,7 @@ SR_PRIV const char *scpi_cmd_get(const struct scpi_command *cmdtable, int comman
return NULL;
cmd = NULL;
- for (i = 0; cmdtable[i].command; i++) {
+ for (i = 0; cmdtable[i].string; i++) {
if (cmdtable[i].command == command) {
cmd = cmdtable[i].string;
break;
@@ -74,8 +75,7 @@ SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, const struct scpi_command *c
if (!(cmd = scpi_cmd_get(cmdtable, command))) {
/* Device does not implement this command, that's OK. */
- /* TODO: deprecate SR_OK_CONTINUE */
- return SR_OK_CONTINUE;
+ return SR_OK;
}
scpi = sdi->conn;
@@ -97,8 +97,8 @@ SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, const struct scpi_comma
const char *cmd;
if (!(cmd = scpi_cmd_get(cmdtable, command))) {
- /* Device does not implement this command, that's OK. */
- return SR_OK_CONTINUE;
+ /* Device does not implement this command. */
+ return SR_ERR_NA;
}
scpi = sdi->conn;
@@ -112,19 +112,19 @@ SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, const struct scpi_comma
if (g_variant_type_equal(gvtype, G_VARIANT_TYPE_BOOLEAN)) {
if ((ret = sr_scpi_get_string(scpi, NULL, &s)) != SR_OK)
return ret;
- if (!strcasecmp(s, "ON") || !strcasecmp(s, "1")
- || !strcasecmp(s, "YES"))
+ if (!g_ascii_strcasecmp(s, "ON") || !g_ascii_strcasecmp(s, "1")
+ || !g_ascii_strcasecmp(s, "YES"))
*gvar = g_variant_new_boolean(TRUE);
- else if (!strcasecmp(s, "OFF") || !strcasecmp(s, "0")
- || !strcasecmp(s, "NO"))
+ else if (!g_ascii_strcasecmp(s, "OFF") || !g_ascii_strcasecmp(s, "0")
+ || !g_ascii_strcasecmp(s, "NO"))
*gvar = g_variant_new_boolean(FALSE);
else
ret = SR_ERR;
g_free(s);
- } if (g_variant_type_equal(gvtype, G_VARIANT_TYPE_DOUBLE)) {
+ } else if (g_variant_type_equal(gvtype, G_VARIANT_TYPE_DOUBLE)) {
if ((ret = sr_scpi_get_double(scpi, NULL, &d)) == SR_OK)
*gvar = g_variant_new_double(d);
- } if (g_variant_type_equal(gvtype, G_VARIANT_TYPE_STRING)) {
+ } else if (g_variant_type_equal(gvtype, G_VARIANT_TYPE_STRING)) {
if ((ret = sr_scpi_get_string(scpi, NULL, &s)) == SR_OK)
*gvar = g_variant_new_string(s);
} else {