]> sigrok.org Git - libsigrok.git/commitdiff
scpi: Support devices that omit serial number in *IDN? command responses.
authorTimo Kokkonen <redacted>
Tue, 2 Jun 2020 07:42:54 +0000 (00:42 -0700)
committerGerhard Sittig <redacted>
Mon, 17 Aug 2020 16:35:17 +0000 (18:35 +0200)
src/scpi/scpi.c

index 2477cf2323971c314880c3bc235732fd076c0af3..cc213ff87e013788bc35676ba217658ca596fb4e 100644 (file)
@@ -1117,8 +1117,8 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi,
         */
        tokens = g_strsplit(response, ",", 0);
        num_tokens = g_strv_length(tokens);
-       if (num_tokens < 4) {
-               sr_dbg("IDN response not according to spec: %80.s.", response);
+       if (num_tokens < 3) {
+               sr_dbg("IDN response not according to spec: '%s'", response);
                g_strfreev(tokens);
                g_free(response);
                return SR_ERR_DATA;
@@ -1134,8 +1134,13 @@ SR_PRIV int sr_scpi_get_hw_id(struct sr_scpi_dev_inst *scpi,
                hw_info->manufacturer = g_strstrip(g_strdup(idn_substr + 4));
 
        hw_info->model = g_strstrip(g_strdup(tokens[1]));
-       hw_info->serial_number = g_strstrip(g_strdup(tokens[2]));
-       hw_info->firmware_version = g_strstrip(g_strdup(tokens[3]));
+       if (num_tokens < 4) {
+               hw_info->serial_number = g_strdup("Unknown");
+               hw_info->firmware_version = g_strstrip(g_strdup(tokens[2]));
+       } else {
+               hw_info->serial_number = g_strstrip(g_strdup(tokens[2]));
+               hw_info->firmware_version = g_strstrip(g_strdup(tokens[3]));
+       }
 
        g_strfreev(tokens);