]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/serial-dmm/api.c
Change sr_dev_inst_new() to take no parameters.
[libsigrok.git] / src / hardware / serial-dmm / api.c
index a401dd65bf12ee9a337f3fa32d35b92c4324ace6..87e63b10f4f07b6413c056ebdd0e60d4632992ce 100644 (file)
 #include "libsigrok-internal.h"
 #include "protocol.h"
 
-static const int32_t hwopts[] = {
+static const uint32_t scanopts[] = {
        SR_CONF_CONN,
        SR_CONF_SERIALCOMM,
 };
 
-static const int32_t hwcaps[] = {
+static const uint32_t devopts[] = {
        SR_CONF_MULTIMETER,
-       SR_CONF_LIMIT_SAMPLES,
-       SR_CONF_LIMIT_MSEC,
        SR_CONF_CONTINUOUS,
+       SR_CONF_LIMIT_SAMPLES | SR_CONF_SET,
+       SR_CONF_LIMIT_MSEC | SR_CONF_SET,
 };
 
 SR_PRIV struct sr_dev_driver bbcgm_m2110_driver_info;
@@ -64,6 +64,9 @@ SR_PRIV struct sr_dev_driver voltcraft_me42_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc830_ser_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_vc920_ser_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_vc940_ser_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_vc960_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60a_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60e_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60g_ser_driver_info;
@@ -71,10 +74,15 @@ SR_PRIV struct sr_dev_driver uni_t_ut61b_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut61c_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut61d_ser_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut61e_ser_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut71a_ser_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut71b_ser_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut71c_ser_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut71d_ser_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut71e_ser_driver_info;
 SR_PRIV struct sr_dev_driver iso_tech_idm103n_driver_info;
 SR_PRIV struct sr_dev_driver tenma_72_7745_ser_driver_info;
 SR_PRIV struct sr_dev_driver tenma_72_7750_ser_driver_info;
-SR_PRIV struct sr_dev_driver brymen_bm25x_ser_driver_info;
+SR_PRIV struct sr_dev_driver brymen_bm25x_driver_info;
 
 SR_PRIV struct dmm_info dmms[] = {
        {
@@ -247,6 +255,27 @@ SR_PRIV struct dmm_info dmms[] = {
                &voltcraft_vc840_ser_driver_info,
                receive_data_VOLTCRAFT_VC840_SER,
        },
+       {
+               "Voltcraft", "VC-920 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &voltcraft_vc920_ser_driver_info,
+               receive_data_VOLTCRAFT_VC920_SER,
+       },
+       {
+               "Voltcraft", "VC-940 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &voltcraft_vc940_ser_driver_info,
+               receive_data_VOLTCRAFT_VC940_SER,
+       },
+       {
+               "Voltcraft", "VC-960 (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &voltcraft_vc960_ser_driver_info,
+               receive_data_VOLTCRAFT_VC960_SER,
+       },
        {
                "UNI-T", "UT60A (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
                2400, FS9721_PACKET_SIZE, 0, 0, NULL,
@@ -297,6 +326,36 @@ SR_PRIV struct dmm_info dmms[] = {
                NULL,
                &uni_t_ut61e_ser_driver_info, receive_data_UNI_T_UT61E_SER,
        },
+       {
+               "UNI-T", "UT71A (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &uni_t_ut71a_ser_driver_info, receive_data_UNI_T_UT71A_SER,
+       },
+       {
+               "UNI-T", "UT71B (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &uni_t_ut71b_ser_driver_info, receive_data_UNI_T_UT71B_SER,
+       },
+       {
+               "UNI-T", "UT71C (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &uni_t_ut71c_ser_driver_info, receive_data_UNI_T_UT71C_SER,
+       },
+       {
+               "UNI-T", "UT71D (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &uni_t_ut71d_ser_driver_info, receive_data_UNI_T_UT71D_SER,
+       },
+       {
+               "UNI-T", "UT71E (UT-D02 cable)", "2400/7o1/rts=0/dtr=1",
+               2400, UT71X_PACKET_SIZE, 0, 0, NULL,
+               sr_ut71x_packet_valid, sr_ut71x_parse, NULL,
+               &uni_t_ut71e_ser_driver_info, receive_data_UNI_T_UT71E_SER,
+       },
        {
                "ISO-TECH", "IDM103N", "2400/7o1/rts=0/dtr=1",
                2400, ES519XX_11B_PACKET_SIZE, 0, 0, NULL,
@@ -320,11 +379,11 @@ SR_PRIV struct dmm_info dmms[] = {
                &tenma_72_7750_ser_driver_info, receive_data_TENMA_72_7750_SER,
        },
        {
-               "Brymen", "BM25x (BC20X cable)", "9600/8n1/rts=1/dtr=1",
+               "Brymen", "BM25x", "9600/8n1/rts=1/dtr=1",
                9600, BRYMEN_BM25X_PACKET_SIZE, 0, 0, NULL,
                sr_brymen_bm25x_packet_valid, sr_brymen_bm25x_parse,
                NULL,
-               &brymen_bm25x_ser_driver_info, receive_data_BRYMEN_BM25X_SER,
+               &brymen_bm25x_driver_info, receive_data_BRYMEN_BM25X,
        },
 };
 
@@ -353,7 +412,7 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
        if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
                return NULL;
 
-       if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
+       if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
 
        sr_info("Probing serial port %s.", conn);
@@ -397,9 +456,10 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, dmms[dmm].vendor,
-                                   dmms[dmm].device, NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(dmms[dmm].vendor);
+       sdi->model = g_strdup(dmms[dmm].device);
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
@@ -465,7 +525,7 @@ static int cleanup(int dmm)
        return dev_clear(dmm);
 }
 
-static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
+static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
@@ -480,7 +540,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
                return SR_ERR_BUG;
        }
 
-       switch (id) {
+       switch (key) {
        case SR_CONF_LIMIT_SAMPLES:
                devc->limit_samples = g_variant_get_uint64(data);
                sr_dbg("Setting sample limit to %" PRIu64 ".",
@@ -498,7 +558,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
        return SR_OK;
 }
 
-static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
+static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
                const struct sr_channel_group *cg)
 {
        (void)sdi;
@@ -506,12 +566,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t));
                break;
        case SR_CONF_DEVICE_OPTIONS:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
-                               hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+                               devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
                break;
        default:
                return SR_ERR_NA;
@@ -626,6 +686,9 @@ DRV(voltcraft_me42, VOLTCRAFT_ME42, "voltcraft-me42", "Voltcraft ME-42")
 DRV(voltcraft_vc820_ser, VOLTCRAFT_VC820_SER, "voltcraft-vc820-ser", "Voltcraft VC-820 (UT-D02 cable)")
 DRV(voltcraft_vc830_ser, VOLTCRAFT_VC830_SER, "voltcraft-vc830-ser", "Voltcraft VC-830 (UT-D02 cable)")
 DRV(voltcraft_vc840_ser, VOLTCRAFT_VC840_SER, "voltcraft-vc840-ser", "Voltcraft VC-840 (UT-D02 cable)")
+DRV(voltcraft_vc920_ser, VOLTCRAFT_VC920_SER, "voltcraft-vc920-ser", "Voltcraft VC-920 (UT-D02 cable)")
+DRV(voltcraft_vc940_ser, VOLTCRAFT_VC940_SER, "voltcraft-vc940-ser", "Voltcraft VC-940 (UT-D02 cable)")
+DRV(voltcraft_vc960_ser, VOLTCRAFT_VC960_SER, "voltcraft-vc960-ser", "Voltcraft VC-960 (UT-D02 cable)")
 DRV(uni_t_ut60a_ser, UNI_T_UT60A_SER, "uni-t-ut60a-ser", "UNI-T UT60A (UT-D02 cable)")
 DRV(uni_t_ut60e_ser, UNI_T_UT60E_SER, "uni-t-ut60e-ser", "UNI-T UT60E (UT-D02 cable)")
 DRV(uni_t_ut60g_ser, UNI_T_UT60G_SER, "uni-t-ut60g-ser", "UNI-T UT60G (UT-D02 cable)")
@@ -633,7 +696,12 @@ DRV(uni_t_ut61b_ser, UNI_T_UT61B_SER, "uni-t-ut61b-ser", "UNI-T UT61B (UT-D02 ca
 DRV(uni_t_ut61c_ser, UNI_T_UT61C_SER, "uni-t-ut61c-ser", "UNI-T UT61C (UT-D02 cable)")
 DRV(uni_t_ut61d_ser, UNI_T_UT61D_SER, "uni-t-ut61d-ser", "UNI-T UT61D (UT-D02 cable)")
 DRV(uni_t_ut61e_ser, UNI_T_UT61E_SER, "uni-t-ut61e-ser", "UNI-T UT61E (UT-D02 cable)")
+DRV(uni_t_ut71a_ser, UNI_T_UT71A_SER, "uni-t-ut71a-ser", "UNI-T UT71A (UT-D02 cable)")
+DRV(uni_t_ut71b_ser, UNI_T_UT71B_SER, "uni-t-ut71b-ser", "UNI-T UT71B (UT-D02 cable)")
+DRV(uni_t_ut71c_ser, UNI_T_UT71C_SER, "uni-t-ut71c-ser", "UNI-T UT71C (UT-D02 cable)")
+DRV(uni_t_ut71d_ser, UNI_T_UT71D_SER, "uni-t-ut71d-ser", "UNI-T UT71D (UT-D02 cable)")
+DRV(uni_t_ut71e_ser, UNI_T_UT71E_SER, "uni-t-ut71e-ser", "UNI-T UT71E (UT-D02 cable)")
 DRV(iso_tech_idm103n, ISO_TECH_IDM103N, "iso-tech-idm103n", "ISO-TECH IDM103N")
 DRV(tenma_72_7745_ser, TENMA_72_7745_SER, "tenma-72-7745-ser", "Tenma 72-7745 (UT-D02 cable)")
 DRV(tenma_72_7750_ser, TENMA_72_7750_SER, "tenma-72-7750-ser", "Tenma 72-7750 (UT-D02 cable)")
-DRV(brymen_bm25x_ser, BRYMEN_BM25X_SER, "brymen-bm25x-ser", "Brymen BM25x (BC20X cable)")
+DRV(brymen_bm25x, BRYMEN_BM25X, "brymen-bm25x", "Brymen BM25x")