]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/serial-dmm/api.c
Removal of sdi->index, step 4: fix trivial sr_dev_inst_new() calls
[libsigrok.git] / src / hardware / serial-dmm / api.c
index b96c7a0da982c18431a2b02697843bbf71f77e38..7fdfd50e9849ef694a6a1364e1ec4d3388803266 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;
@@ -74,6 +74,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut61e_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 dmm_info dmms[] = {
        {
@@ -318,6 +319,13 @@ SR_PRIV struct dmm_info dmms[] = {
                NULL,
                &tenma_72_7750_ser_driver_info, receive_data_TENMA_72_7750_SER,
        },
+       {
+               "Brymen", "BM25x (BC20X cable)", "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,
+       },
 };
 
 static int dev_clear(int dmm)
@@ -327,8 +335,6 @@ static int dev_clear(int dmm)
 
 static int init(struct sr_context *sr_ctx, int dmm)
 {
-       sr_dbg("Selected '%s' subdriver.", dmms[dmm].di->name);
-
        return std_init(sr_ctx, dmms[dmm].di, LOG_PREFIX);
 }
 
@@ -347,7 +353,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);
@@ -391,7 +397,7 @@ 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,
+       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, dmms[dmm].vendor,
                                    dmms[dmm].device, NULL)))
                goto scan_cleanup;
 
@@ -459,7 +465,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;
@@ -474,7 +480,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 ".",
@@ -492,7 +498,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;
@@ -500,12 +506,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;
@@ -630,3 +636,4 @@ DRV(uni_t_ut61e_ser, UNI_T_UT61E_SER, "uni-t-ut61e-ser", "UNI-T UT61E (UT-D02 ca
 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)")