* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <config.h>
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
-#include <errno.h>
-#include "libsigrok.h"
+#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#include "fluke-dmm.h"
SR_PRIV struct sr_dev_driver flukedmm_driver_info;
-static char *scan_conn[] = {
+static const char *scan_conn[] = {
/* 287/289 */
"115200/8n1",
/* 187/189 */
{ 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)
{
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
- drvc = di->priv;
+ drvc = di->context;
b = buf;
retry = 0;
devices = NULL;
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)
{
switch (key) {
case SR_CONF_LIMIT_MSEC:
/* TODO: not yet implemented */
- if (g_variant_get_uint64(data) == 0) {
- sr_err("LIMIT_MSEC can't be 0.");
- return SR_ERR;
- }
devc->limit_msec = g_variant_get_uint64(data);
- sr_dbg("Setting time limit to %" PRIu64 "ms.",
- devc->limit_msec);
break;
case SR_CONF_LIMIT_SAMPLES:
devc->limit_samples = g_variant_get_uint64(data);
- sr_dbg("Setting sample limit to %" PRIu64 ".",
- devc->limit_samples);
break;
default:
return SR_ERR_NA;
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;
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);
+ std_session_send_df_header(sdi, LOG_PREFIX);
/* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn;
return SR_OK;
}
-static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{
- return std_serial_dev_acquisition_stop(sdi, cb_data, std_serial_dev_close,
+ return std_serial_dev_acquisition_stop(sdi, std_serial_dev_close,
sdi->conn, LOG_PREFIX);
}
.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,
.dev_close = std_serial_dev_close,
.dev_acquisition_start = dev_acquisition_start,
.dev_acquisition_stop = dev_acquisition_stop,
- .priv = NULL,
+ .context = NULL,
};