]> sigrok.org Git - libsigrok.git/blobdiff - hardware/uni-t-dmm/api.c
uni-t-dmm: Add support for the Voltcraft VC-840.
[libsigrok.git] / hardware / uni-t-dmm / api.c
index cfb6ae6be8b06602b305db8e88ef87bb0a61e3ec..7cf29fcbb3a08a0b3d620d6b47057513df454bed 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the libsigrok project.
  *
- * Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012-2013 Uwe Hermann <uwe@hermann-uwe.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -38,23 +38,39 @@ static const int32_t hwcaps[] = {
 };
 
 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_vc840_driver_info;
 
 SR_PRIV struct dmm_info udmms[] = {
        {
-               "UNI-T", "UT61D", 19230 /* TODO */,
+               "UNI-T", "UT61D", 19230,
                FS9922_PACKET_SIZE, NULL,
                sr_fs9922_packet_valid, sr_fs9922_parse,
                NULL,
                &uni_t_ut61d_driver_info, receive_data_UNI_T_UT61D,
        },
        {
-               "Voltcraft VC-820", "VC-820", 19200 /* TODO */,
+               "UNI-T", "UT61E", 19230,
+               ES51922_PACKET_SIZE, NULL,
+               sr_es51922_packet_valid, sr_es51922_parse,
+               NULL,
+               &uni_t_ut61e_driver_info, receive_data_UNI_T_UT61E,
+       },
+       {
+               "Voltcraft", "VC-820", 2400,
                FS9721_PACKET_SIZE, NULL,
                sr_fs9721_packet_valid, sr_fs9721_parse,
                NULL,
                &voltcraft_vc820_driver_info, receive_data_VOLTCRAFT_VC820,
        },
+       {
+               "Voltcraft", "VC-840", 2400,
+               FS9721_PACKET_SIZE, NULL,
+               sr_fs9721_packet_valid, sr_fs9721_parse,
+               NULL,
+               &voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840,
+       },
 };
 
 static int clear_instances(int dmm)
@@ -70,7 +86,7 @@ static int hw_init(struct sr_context *sr_ctx, int dmm)
 {
        sr_dbg("Selected '%s' subdriver.", udmms[dmm].di->name);
 
-       return std_hw_init(sr_ctx, uddms[dmm].di, DRIVER_LOG_DOMAIN);
+       return std_hw_init(sr_ctx, udmms[dmm].di, DRIVER_LOG_DOMAIN);
 }
 
 static GSList *hw_scan(GSList *options, int dmm)
@@ -84,13 +100,8 @@ static GSList *hw_scan(GSList *options, int dmm)
        struct sr_probe *probe;
        const char *conn;
 
-       (void)options;
-
        drvc = udmms[dmm].di->priv;
 
-       /* USB scan is always authoritative. */
-       clear_instances(dmm);
-
        conn = NULL;
        for (l = options; l; l = l->next) {
                src = l->data;
@@ -117,6 +128,8 @@ static GSList *hw_scan(GSList *options, int dmm)
                        return NULL;
                }
 
+               devc->first_run = TRUE;
+
                if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
                                udmms[dmm].vendor, udmms[dmm].device, NULL))) {
                        sr_err("sr_dev_inst_new returned NULL.");
@@ -128,7 +141,8 @@ static GSList *hw_scan(GSList *options, int dmm)
                        return NULL;
                sdi->probes = g_slist_append(sdi->probes, probe);
 
-               devc->usb = usb;
+               sdi->inst_type = SR_INST_USB;
+               sdi->conn = usb;
 
                drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
@@ -139,22 +153,22 @@ static GSList *hw_scan(GSList *options, int dmm)
 
 static GSList *hw_dev_list(int dmm)
 {
-       return ((struct drv_context *)(udmms[dmm]->priv))->instances;
+       return ((struct drv_context *)(udmms[dmm].di->priv))->instances;
 }
 
 static int hw_dev_open(struct sr_dev_inst *sdi, int dmm)
 {
        struct drv_context *drvc;
-       struct dev_context *devc;
-    int ret;
+       struct sr_usb_dev_inst *usb;
+       int ret;
 
        drvc = udmms[dmm].di->priv;
-       devc = sdi->priv;
+       usb = sdi->conn;
 
-    if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, devc->usb)) == SR_OK)
-        sdi->status = SR_ST_ACTIVE;
+       if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) == SR_OK)
+               sdi->status = SR_ST_ACTIVE;
 
-    return ret;
+       return ret;
 }
 
 static int hw_dev_close(struct sr_dev_inst *sdi)
@@ -163,7 +177,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi)
 
        /* TODO */
 
-    sdi->status = SR_ST_INACTIVE;
+       sdi->status = SR_ST_INACTIVE;
 
        return SR_OK;
 }
@@ -210,7 +224,6 @@ 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)
 {
-
        (void)sdi;
 
        switch (key) {
@@ -312,4 +325,6 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
 };
 
 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_vc840, VOLTCRAFT_VC840, "voltcraft-vc840", "Voltcraft VC-840")