]> sigrok.org Git - libsigrok.git/blobdiff - hardware/uni-t-dmm/api.c
build: Portability fixes.
[libsigrok.git] / hardware / uni-t-dmm / api.c
index 84a288b9c9d6207a479746794360d580223592d9..f98c4f5e39e32654fc2fd3e87a1b99577e2dab7e 100644 (file)
@@ -40,60 +40,79 @@ static const int32_t hwcaps[] = {
 SR_PRIV struct sr_dev_driver tecpel_dmm_8061_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60a_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60e_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut60g_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut61b_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut61c_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut61e_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc830_driver_info;
 SR_PRIV struct sr_dev_driver voltcraft_vc840_driver_info;
+SR_PRIV struct sr_dev_driver tenma_72_7745_driver_info;
+SR_PRIV struct sr_dev_driver tenma_72_7750_driver_info;
 
 SR_PRIV struct dmm_info udmms[] = {
        {
                "Tecpel", "DMM-8061", 2400,
-               FS9721_PACKET_SIZE, NULL,
+               FS9721_PACKET_SIZE,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                sr_fs9721_00_temp_c,
                &tecpel_dmm_8061_driver_info, receive_data_TECPEL_DMM_8061,
        },
        {
                "UNI-T", "UT60A", 2400,
-               FS9721_PACKET_SIZE, NULL,
+               FS9721_PACKET_SIZE,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                NULL,
                &uni_t_ut60a_driver_info, receive_data_UNI_T_UT60A,
        },
        {
                "UNI-T", "UT60E", 2400,
-               FS9721_PACKET_SIZE, NULL,
+               FS9721_PACKET_SIZE,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                sr_fs9721_00_temp_c,
                &uni_t_ut60e_driver_info, receive_data_UNI_T_UT60E,
        },
+       {
+               /* The baudrate is actually 19230, see "Note 1" below. */
+               "UNI-T", "UT60G", 19200,
+               ES519XX_11B_PACKET_SIZE,
+               sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse,
+               NULL,
+               &uni_t_ut60g_driver_info, receive_data_UNI_T_UT60G,
+       },
+       {
+               "UNI-T", "UT61B", 2400,
+               FS9922_PACKET_SIZE,
+               sr_fs9922_packet_valid, sr_fs9922_parse,
+               NULL,
+               &uni_t_ut61b_driver_info, receive_data_UNI_T_UT61B,
+       },
+       {
+               "UNI-T", "UT61C", 2400,
+               FS9922_PACKET_SIZE,
+               sr_fs9922_packet_valid, sr_fs9922_parse,
+               NULL,
+               &uni_t_ut61c_driver_info, receive_data_UNI_T_UT61C,
+       },
        {
                "UNI-T", "UT61D", 2400,
-               FS9922_PACKET_SIZE, NULL,
+               FS9922_PACKET_SIZE,
                sr_fs9922_packet_valid, sr_fs9922_parse,
                NULL,
                &uni_t_ut61d_driver_info, receive_data_UNI_T_UT61D,
        },
        {
-               /*
-                * Important: The actual baudrate of the Cyrustek ES51922 chip
-                * used in this DMM is 19230. However, the WCH CH9325 chip
-                * (UART to USB/HID) used in (some versions of) the UNI-T
-                * UT-D04 cable doesn't support 19230 baud. It only supports
-                * 19200, and setting an unsupported baudrate will result in
-                * the default of 2400 being used (which will not work with
-                * this DMM, of course).
-                */
+               /* The baudrate is actually 19230, see "Note 1" below. */
                "UNI-T", "UT61E", 19200,
-               ES51922_PACKET_SIZE, NULL,
-               sr_es51922_packet_valid, sr_es51922_parse,
+               ES519XX_14B_PACKET_SIZE,
+               sr_es519xx_19200_14b_packet_valid, sr_es519xx_19200_14b_parse,
                NULL,
                &uni_t_ut61e_driver_info, receive_data_UNI_T_UT61E,
        },
        {
                "Voltcraft", "VC-820", 2400,
-               FS9721_PACKET_SIZE, NULL,
+               FS9721_PACKET_SIZE,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                NULL,
                &voltcraft_vc820_driver_info, receive_data_VOLTCRAFT_VC820,
@@ -105,20 +124,43 @@ SR_PRIV struct dmm_info udmms[] = {
                 * bit "z1" to indicate "diode mode" and "voltage".
                 */
                "Voltcraft", "VC-830", 2400,
-               FS9922_PACKET_SIZE, NULL,
+               FS9922_PACKET_SIZE,
                sr_fs9922_packet_valid, sr_fs9922_parse,
                &sr_fs9922_z1_diode,
                &voltcraft_vc830_driver_info, receive_data_VOLTCRAFT_VC830,
        },
        {
                "Voltcraft", "VC-840", 2400,
-               FS9721_PACKET_SIZE, NULL,
+               FS9721_PACKET_SIZE,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                sr_fs9721_00_temp_c,
                &voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840,
        },
+       {
+               "Tenma", "72-7745", 2400,
+               FS9721_PACKET_SIZE,
+               sr_fs9721_packet_valid, sr_fs9721_parse,
+               sr_fs9721_00_temp_c,
+               &tenma_72_7745_driver_info, receive_data_TENMA_72_7745,
+       },
+       {
+               /* The baudrate is actually 19230, see "Note 1" below. */
+               "Tenma", "72-7750", 19200,
+               ES519XX_11B_PACKET_SIZE,
+               sr_es519xx_19200_11b_packet_valid, sr_es519xx_19200_11b_parse,
+               NULL,
+               &tenma_72_7750_driver_info, receive_data_TENMA_72_7750,
+       },
 };
 
+/*
+ * Note 1: The actual baudrate of the Cyrustek ES519xx chip used in this DMM
+ * is 19230. However, the WCH CH9325 chip (UART to USB/HID) used in (some
+ * versions of) the UNI-T UT-D04 cable doesn't support 19230 baud. It only
+ * supports 19200, and setting an unsupported baudrate will result in the
+ * default of 2400 being used (which will not work with this DMM, of course).
+ */
+
 static int dev_clear(int dmm)
 {
        return std_dev_clear(udmms[dmm].di, NULL);
@@ -139,7 +181,7 @@ static GSList *scan(GSList *options, int dmm)
        struct drv_context *drvc;
        struct sr_usb_dev_inst *usb;
        struct sr_config *src;
-       struct sr_probe *probe;
+       struct sr_channel *ch;
        const char *conn;
 
        drvc = udmms[dmm].di->priv;
@@ -179,9 +221,9 @@ static GSList *scan(GSList *options, int dmm)
                }
                sdi->priv = devc;
                sdi->driver = udmms[dmm].di;
-               if (!(probe = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
+               if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
                        return NULL;
-               sdi->probes = g_slist_append(sdi->probes, probe);
+               sdi->channels = g_slist_append(sdi->channels, ch);
 
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
@@ -215,8 +257,6 @@ static int dev_open(struct sr_dev_inst *sdi, int dmm)
 
 static int dev_close(struct sr_dev_inst *sdi)
 {
-       (void)sdi;
-
        /* TODO */
 
        sdi->status = SR_ST_INACTIVE;
@@ -230,11 +270,11 @@ static int cleanup(int dmm)
 }
 
 static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
-               const struct sr_probe_group *probe_group)
+               const struct sr_channel_group *cg)
 {
        struct dev_context *devc;
 
-       (void)probe_group;
+       (void)cg;
 
        devc = sdi->priv;
 
@@ -265,10 +305,10 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
 }
 
 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
-               const struct sr_probe_group *probe_group)
+               const struct sr_channel_group *cg)
 {
        (void)sdi;
-       (void)probe_group;
+       (void)cg;
 
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
@@ -298,9 +338,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        devc->starttime = g_get_monotonic_time();
 
        /* Send header packet to the session bus. */
-       std_session_send_df_header(cb_data, LOG_PREFIX);
+       std_session_send_df_header(sdi, LOG_PREFIX);
 
-       sr_source_add(0, 0, 10 /* poll_timeout */,
+       sr_session_source_add(sdi->session, 0, 0, 10 /* poll_timeout */,
                      udmms[dmm].receive_data, (void *)sdi);
 
        return SR_OK;
@@ -310,17 +350,16 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        struct sr_datafeed_packet packet;
 
-       (void)sdi;
+       (void)cb_data;
 
        sr_dbg("Stopping acquisition.");
 
        /* Send end packet to the session bus. */
        sr_dbg("Sending SR_DF_END.");
        packet.type = SR_DF_END;
-       sr_session_send(cb_data, &packet);
+       sr_session_send(sdi, &packet);
 
-       /* TODO? */
-       sr_source_remove(0);
+       sr_session_source_remove(sdi->session, 0);
 
        return SR_OK;
 }
@@ -373,8 +412,13 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
 DRV(tecpel_dmm_8061, TECPEL_DMM_8061, "tecpel-dmm-8061", "Tecpel DMM-8061")
 DRV(uni_t_ut60a, UNI_T_UT60A, "uni-t-ut60a", "UNI-T UT60A")
 DRV(uni_t_ut60e, UNI_T_UT60E, "uni-t-ut60e", "UNI-T UT60E")
+DRV(uni_t_ut60g, UNI_T_UT60G, "uni-t-ut60g", "UNI-T UT60G")
+DRV(uni_t_ut61b, UNI_T_UT61B, "uni-t-ut61b", "UNI-T UT61B")
+DRV(uni_t_ut61c, UNI_T_UT61C, "uni-t-ut61c", "UNI-T UT61C")
 DRV(uni_t_ut61d, UNI_T_UT61D, "uni-t-ut61d", "UNI-T UT61D")
 DRV(uni_t_ut61e, UNI_T_UT61E, "uni-t-ut61e", "UNI-T UT61E")
 DRV(voltcraft_vc820, VOLTCRAFT_VC820, "voltcraft-vc820", "Voltcraft VC-820")
 DRV(voltcraft_vc830, VOLTCRAFT_VC830, "voltcraft-vc830", "Voltcraft VC-830")
 DRV(voltcraft_vc840, VOLTCRAFT_VC840, "voltcraft-vc840", "Voltcraft VC-840")
+DRV(tenma_72_7745, TENMA_72_7745, "tenma-72-7745", "Tenma 72-7745")
+DRV(tenma_72_7750, TENMA_72_7750, "tenma-72-7750", "Tenma 72-7750")