]> sigrok.org Git - libsigrok.git/commitdiff
deree-de5000: prepare to add more ES51919 based LCR meters
authorGerhard Sittig <redacted>
Sun, 6 Nov 2016 21:01:37 +0000 (22:01 +0100)
committerUwe Hermann <redacted>
Mon, 5 Dec 2016 00:06:58 +0000 (01:06 +0100)
The "deree-de5000" driver is a very thin wrapper around the ES51919
chipset. We expect more models from other vendors to use that same
support code.

Model the registration of vendor/model combinations after the serial-dmm
approach. Register the DER EE DE-5000 device as the currently only
member in a list of drivers which all use the ES51919 chipset (no model
specific routines are registered in the absence of support for other LCR
meter chips).

This commit does not change the driver's behaviour nor the set of
supported hardware. It prepares the addition of more drivers in the
future.

src/hardware/deree-de5000/api.c

index a20f817a4a732a6189035e47469f3420199d2cf8..d61f5c6730cbb73c22721efac22d6e1b036c9bc4 100644 (file)
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 
-#define LOG_PREFIX "deree-de5000"
+#define LOG_PREFIX "serial-lcr-es51919"
+
+struct lcr_es51919_info {
+       struct sr_dev_driver di;
+       const char *vendor;
+       const char *model;
+};
 
 static int dev_clear(const struct sr_dev_driver *di)
 {
@@ -34,30 +40,40 @@ static int dev_clear(const struct sr_dev_driver *di)
 
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
+       struct lcr_es51919_info *lcr;
        struct sr_dev_inst *sdi;
 
-       if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000")))
+       lcr = (struct lcr_es51919_info *)di;
+
+       if (!(sdi = es51919_serial_scan(options, lcr->vendor, lcr->model)))
                return NULL;
 
        return std_scan_complete(di, g_slist_append(NULL, sdi));
 }
 
-static struct sr_dev_driver deree_de5000_driver_info = {
-       .name = "deree-de5000",
-       .longname = "DER EE DE-5000",
-       .api_version = 1,
-       .init = std_init,
-       .cleanup = std_cleanup,
-       .scan = scan,
-       .dev_list = std_dev_list,
-       .dev_clear = dev_clear,
-       .config_get = es51919_serial_config_get,
-       .config_set = es51919_serial_config_set,
-       .config_list = es51919_serial_config_list,
-       .dev_open = std_serial_dev_open,
-       .dev_close = std_serial_dev_close,
-       .dev_acquisition_start = es51919_serial_acquisition_start,
-       .dev_acquisition_stop = std_serial_dev_acquisition_stop,
-       .context = NULL,
-};
-SR_REGISTER_DEV_DRIVER(deree_de5000_driver_info);
+#define LCR_ES51919(id, vendor, model) \
+       &((struct lcr_es51919_info) { \
+               { \
+                       .name = id, \
+                       .longname = vendor " " model, \
+                       .api_version = 1, \
+                       .init = std_init, \
+                       .cleanup = std_cleanup, \
+                       .scan = scan, \
+                       .dev_list = std_dev_list, \
+                       .dev_clear = dev_clear, \
+                       .config_get = es51919_serial_config_get, \
+                       .config_set = es51919_serial_config_set, \
+                       .config_list = es51919_serial_config_list, \
+                       .dev_open = std_serial_dev_open, \
+                       .dev_close = std_serial_dev_close, \
+                       .dev_acquisition_start = es51919_serial_acquisition_start, \
+                       .dev_acquisition_stop = std_serial_dev_acquisition_stop, \
+                       .context = NULL, \
+               }, \
+               vendor, model, \
+       }).di
+
+SR_REGISTER_DEV_DRIVER_LIST(lcr_es51919_drivers,
+       LCR_ES51919("deree-de5000", "DER EE", "DE-5000"),
+);