]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds/api.c
scpi: add VXI transport support
[libsigrok.git] / hardware / rigol-ds / api.c
index 220c29d48f541725455c982815001f4d3e7f3baf..9007ea18d0b70c51e534f24e1fb354df25269755 100644 (file)
@@ -248,7 +248,8 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
        struct sr_dev_inst *sdi;
        const char *usbtmc_prefix = "/dev/usbtmc";
        const char *tcp_prefix = "tcp/";
-       gchar **tokens, *address, *port;
+       const char *vxi_prefix = "vxi/";
+       gchar **tokens, *address, *port, *instrument;
        struct sr_scpi_dev_inst *scpi;
        struct sr_scpi_hw_info *hw_info;
        struct sr_probe *probe;
@@ -276,6 +277,20 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
                g_strfreev(tokens);
                if (!scpi)
                        return SR_ERR_MALLOC;
+       } else if (HAVE_RPC && !strncmp(resource, vxi_prefix, strlen(vxi_prefix))) {
+               sr_dbg("Opening VXI connection %s.", resource);
+               tokens = g_strsplit(resource + strlen(tcp_prefix), "/", 0);
+               address = tokens[0];
+               instrument = tokens[1];
+               if (!address) {
+                       sr_err("Invalid parameters.");
+                       g_strfreev(tokens);
+                       return SR_ERR_ARG;
+               }
+               scpi = scpi_vxi_dev_inst_new(address, instrument);
+               g_strfreev(tokens);
+               if (!scpi)
+                       return SR_ERR_MALLOC;
        } else {
                sr_dbg("Opening serial device %s.", resource);
                if (!(scpi = scpi_serial_dev_inst_new(resource, serialcomm)))