]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds/api.c
rigol-ds: Support VS5000 series devices.
[libsigrok.git] / hardware / rigol-ds / api.c
index 4c8509196afa22377be05b9bb9a966f6b827ddeb..201a6f5d79e9ea414b93f050d9e78338f115c6e1 100644 (file)
@@ -164,6 +164,16 @@ static const struct rigol_ds_model supported_models[] = {
        {"DS2072", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
        {"DS2102", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
        {"DS2202", RIGOL_DS2000, PROTOCOL_IEEE488_2, {2, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
+       {"VS5022", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, false, 14},
+       {"VS5022D", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, true, 14},
+       {"VS5042", RIGOL_VS5000, PROTOCOL_LEGACY, {10, 1000000000}, {50, 1}, {2, 1000}, false, 14},
+       {"VS5042D", RIGOL_VS5000, PROTOCOL_LEGACY, {10, 1000000000}, {50, 1}, {2, 1000}, true, 14},
+       {"VS5062", RIGOL_VS5000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, false, 14},
+       {"VS5062D", RIGOL_VS5000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, true, 14},
+       {"VS5102", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 14},
+       {"VS5102D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 14},
+       {"VS5202", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 14},
+       {"VS5202D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 14},
 };
 
 SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
@@ -215,11 +225,13 @@ static int init(struct sr_context *sr_ctx)
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static int probe_port(const char *port, const char *serialcomm, GSList **devices)
+static int probe_port(const char *resource, const char *serialcomm, GSList **devices)
 {
        struct dev_context *devc;
        struct sr_dev_inst *sdi;
        const char *usbtmc_prefix = "/dev/usbtmc";
+       const char *tcp_prefix = "tcp/";
+       gchar **tokens, *address, *port;
        struct sr_scpi_dev_inst *scpi;
        struct sr_scpi_hw_info *hw_info;
        struct sr_probe *probe;
@@ -229,12 +241,27 @@ static int probe_port(const char *port, const char *serialcomm, GSList **devices
 
        *devices = NULL;
 
-
-       if (strncmp(port, usbtmc_prefix, strlen(usbtmc_prefix)) == 0) {
-               if (!(scpi = scpi_usbtmc_dev_inst_new(port)))
+       if (strncmp(resource, usbtmc_prefix, strlen(usbtmc_prefix)) == 0) {
+               sr_dbg("Opening USBTMC device %s", resource);
+               if (!(scpi = scpi_usbtmc_dev_inst_new(resource)))
+                       return SR_ERR_MALLOC;
+       } else if (strncmp(resource, tcp_prefix, strlen(tcp_prefix)) == 0) {
+               sr_dbg("Opening TCP connection %s", resource);
+               tokens = g_strsplit(resource + strlen(tcp_prefix), "/", 0);
+               address = tokens[0];
+               port = tokens[1];
+               if (!address || !port || tokens[2]) {
+                       sr_dbg("Invalid parameters");
+                       g_strfreev(tokens);
+                       return SR_ERR_ARG;
+               }
+               scpi = scpi_tcp_dev_inst_new(address, port);
+               g_strfreev(tokens);
+               if (!scpi)
                        return SR_ERR_MALLOC;
        } else {
-               if (!(scpi = scpi_serial_dev_inst_new(port, serialcomm)))
+               sr_dbg("Opening serial device %s", resource);
+               if (!(scpi = scpi_serial_dev_inst_new(resource, serialcomm)))
                        return SR_ERR_MALLOC;
        }