X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Ffluke-dmm%2Fapi.c;h=0ee6c7fa64dea886e134bdca996395cfb888fb32;hb=cf398cc0589fe37589c7e6750cf6b735b77494df;hp=36142fd5587cd3614259a160dff1642bf94b4472;hpb=dcd438ee3523098201c7937e75e55775da3b506f;p=libsigrok.git
diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c
index 36142fd5..0ee6c7fa 100644
--- a/src/hardware/fluke-dmm/api.c
+++ b/src/hardware/fluke-dmm/api.c
@@ -17,15 +17,15 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
#include
#include
-#include
-#include "libsigrok.h"
+#include
#include "libsigrok-internal.h"
-#include "fluke-dmm.h"
+#include "protocol.h"
static const uint32_t scanopts[] = {
SR_CONF_CONN,
@@ -39,8 +39,6 @@ static const uint32_t devopts[] = {
SR_CONF_LIMIT_MSEC | SR_CONF_SET,
};
-SR_PRIV struct sr_dev_driver flukedmm_driver_info;
-
static const char *scan_conn[] = {
/* 287/289 */
"115200/8n1",
@@ -56,18 +54,13 @@ static const struct flukedmm_profile supported_flukedmm[] = {
{ FLUKE_189, "189", 100, 1000 },
{ FLUKE_287, "287", 100, 1000 },
{ FLUKE_190, "199B", 1000, 3500 },
+ { FLUKE_289, "289", 100, 1000 },
};
-static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
-{
- return std_init(sr_ctx, di, LOG_PREFIX);
-}
-
static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
const char *serialcomm)
{
struct sr_dev_inst *sdi;
- struct drv_context *drvc;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
GSList *devices;
@@ -79,7 +72,6 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- drvc = di->priv;
b = buf;
retry = 0;
devices = NULL;
@@ -126,13 +118,12 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
sdi->model = g_strdup(tokens[0] + 6);
sdi->version = g_strdup(tokens[1] + s);
devc = g_malloc0(sizeof(struct dev_context));
+ sr_sw_limits_init(&devc->limits);
devc->profile = &supported_flukedmm[i];
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
sdi->priv = devc;
- sdi->driver = di;
sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
- drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
break;
}
@@ -146,7 +137,7 @@ static GSList *fluke_scan(struct sr_dev_driver *di, const char *conn,
if (!devices)
sr_serial_dev_inst_free(serial);
- return devices;
+ return std_scan_complete(di, devices);
}
static GSList *scan(struct sr_dev_driver *di, GSList *options)
@@ -181,23 +172,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
break;
/* The Scopemeter 199B, at least, requires this
* after all the 115k/9.6k confusion. */
- g_usleep(5000);
+ g_usleep(5 * 1000);
}
}
return devices;
}
-static GSList *dev_list(const struct sr_dev_driver *di)
-{
- return ((struct drv_context *)(di->priv))->instances;
-}
-
-static int cleanup(const struct sr_dev_driver *di)
-{
- return std_dev_clear(di, NULL);
-}
-
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
const struct sr_channel_group *cg)
{
@@ -208,24 +189,9 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!(devc = sdi->priv)) {
- sr_err("sdi->priv was NULL.");
- return SR_ERR_BUG;
- }
+ devc = sdi->priv;
- switch (key) {
- case SR_CONF_LIMIT_MSEC:
- /* TODO: not yet implemented */
- devc->limit_msec = g_variant_get_uint64(data);
- break;
- case SR_CONF_LIMIT_SAMPLES:
- devc->limit_samples = g_variant_get_uint64(data);
- break;
- default:
- return SR_ERR_NA;
- }
-
- return SR_OK;
+ return sr_sw_limits_config_set(&devc->limits, key, data);
}
static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
@@ -250,7 +216,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
return SR_OK;
}
-static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_start(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
@@ -258,15 +224,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED;
- if (!(devc = sdi->priv)) {
- sr_err("sdi->priv was NULL.");
- return SR_ERR_BUG;
- }
-
- devc->cb_data = cb_data;
+ devc = sdi->priv;
- /* Send header packet to the session bus. */
- std_session_send_df_header(cb_data, LOG_PREFIX);
+ sr_sw_limits_acquisition_start(&devc->limits);
+ std_session_send_df_header(sdi);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
@@ -283,20 +244,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
-{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
- sdi->conn, LOG_PREFIX);
-}
-
-SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
+static struct sr_dev_driver flukedmm_driver_info = {
.name = "fluke-dmm",
.longname = "Fluke 18x/28x series DMMs",
.api_version = 1,
- .init = init,
- .cleanup = cleanup,
+ .init = std_init,
+ .cleanup = std_cleanup,
.scan = scan,
- .dev_list = dev_list,
+ .dev_list = std_dev_list,
.dev_clear = NULL,
.config_get = NULL,
.config_set = config_set,
@@ -304,6 +259,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = {
.dev_open = std_serial_dev_open,
.dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
- .dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .dev_acquisition_stop = std_serial_dev_acquisition_stop,
+ .context = NULL,
};
+SR_REGISTER_DEV_DRIVER(flukedmm_driver_info);