2012-10-27 20:41:50 +00:00
|
|
|
/*
|
2013-04-23 20:24:30 +00:00
|
|
|
* This file is part of the libsigrok project.
|
2012-10-27 20:41:50 +00:00
|
|
|
*
|
2013-01-26 22:39:24 +00:00
|
|
|
* Copyright (C) 2012-2013 Uwe Hermann <uwe@hermann-uwe.de>
|
2012-10-27 20:41:50 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "libsigrok.h"
|
|
|
|
#include "libsigrok-internal.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
|
2013-01-20 18:55:33 +00:00
|
|
|
#define UNI_T_UT_D04_NEW "1a86.e008"
|
|
|
|
|
2013-03-31 19:28:33 +00:00
|
|
|
static const int32_t hwopts[] = {
|
2013-01-21 22:40:09 +00:00
|
|
|
SR_CONF_CONN,
|
2013-01-20 18:57:04 +00:00
|
|
|
};
|
|
|
|
|
2013-03-31 19:28:33 +00:00
|
|
|
static const int32_t hwcaps[] = {
|
2013-01-21 22:22:47 +00:00
|
|
|
SR_CONF_MULTIMETER,
|
|
|
|
SR_CONF_LIMIT_SAMPLES,
|
|
|
|
SR_CONF_LIMIT_MSEC,
|
|
|
|
SR_CONF_CONTINUOUS,
|
2012-10-27 20:41:50 +00:00
|
|
|
};
|
|
|
|
|
2013-05-01 01:00:08 +00:00
|
|
|
SR_PRIV struct sr_dev_driver tecpel_dmm_8061_driver_info;
|
2013-07-05 12:02:50 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut60a_driver_info;
|
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut60e_driver_info;
|
2014-01-03 21:32:16 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut60g_driver_info;
|
2014-01-01 14:25:39 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut61b_driver_info;
|
2013-12-29 16:35:51 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut61c_driver_info;
|
2012-10-30 12:11:27 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info;
|
2013-04-29 18:23:21 +00:00
|
|
|
SR_PRIV struct sr_dev_driver uni_t_ut61e_driver_info;
|
2012-10-30 12:11:27 +00:00
|
|
|
SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info;
|
2013-06-22 14:53:13 +00:00
|
|
|
SR_PRIV struct sr_dev_driver voltcraft_vc830_driver_info;
|
2013-04-30 18:27:04 +00:00
|
|
|
SR_PRIV struct sr_dev_driver voltcraft_vc840_driver_info;
|
2013-11-23 11:50:33 +00:00
|
|
|
SR_PRIV struct sr_dev_driver tenma_72_7745_driver_info;
|
2014-01-06 16:20:35 +00:00
|
|
|
SR_PRIV struct sr_dev_driver tenma_72_7750_driver_info;
|
2012-10-30 13:23:05 +00:00
|
|
|
|
2012-12-19 18:01:54 +00:00
|
|
|
SR_PRIV struct dmm_info udmms[] = {
|
2013-05-01 01:00:08 +00:00
|
|
|
{
|
|
|
|
"Tecpel", "DMM-8061", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9721_PACKET_SIZE,
|
2013-05-01 01:00:08 +00:00
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
|
|
|
sr_fs9721_00_temp_c,
|
|
|
|
&tecpel_dmm_8061_driver_info, receive_data_TECPEL_DMM_8061,
|
|
|
|
},
|
2013-07-05 12:02:50 +00:00
|
|
|
{
|
|
|
|
"UNI-T", "UT60A", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9721_PACKET_SIZE,
|
2013-07-05 12:02:50 +00:00
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
|
|
|
NULL,
|
|
|
|
&uni_t_ut60a_driver_info, receive_data_UNI_T_UT60A,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"UNI-T", "UT60E", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9721_PACKET_SIZE,
|
2013-07-05 12:02:50 +00:00
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
|
|
|
sr_fs9721_00_temp_c,
|
|
|
|
&uni_t_ut60e_driver_info, receive_data_UNI_T_UT60E,
|
|
|
|
},
|
2014-01-03 21:32:16 +00:00
|
|
|
{
|
2014-01-06 16:20:35 +00:00
|
|
|
/* The baudrate is actually 19230, see "Note 1" below. */
|
2014-01-03 21:32:16 +00:00
|
|
|
"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,
|
|
|
|
},
|
2013-12-29 16:35:51 +00:00
|
|
|
{
|
2014-01-01 15:40:36 +00:00
|
|
|
"UNI-T", "UT61B", 2400,
|
2013-12-29 16:35:51 +00:00
|
|
|
FS9922_PACKET_SIZE,
|
|
|
|
sr_fs9922_packet_valid, sr_fs9922_parse,
|
|
|
|
NULL,
|
2014-01-01 15:40:36 +00:00
|
|
|
&uni_t_ut61b_driver_info, receive_data_UNI_T_UT61B,
|
2013-12-29 16:35:51 +00:00
|
|
|
},
|
2014-01-01 14:25:39 +00:00
|
|
|
{
|
2014-01-01 15:40:36 +00:00
|
|
|
"UNI-T", "UT61C", 2400,
|
2014-01-01 14:25:39 +00:00
|
|
|
FS9922_PACKET_SIZE,
|
|
|
|
sr_fs9922_packet_valid, sr_fs9922_parse,
|
|
|
|
NULL,
|
2014-01-01 15:40:36 +00:00
|
|
|
&uni_t_ut61c_driver_info, receive_data_UNI_T_UT61C,
|
2014-01-01 14:25:39 +00:00
|
|
|
},
|
2012-12-19 18:01:54 +00:00
|
|
|
{
|
2013-04-30 18:28:29 +00:00
|
|
|
"UNI-T", "UT61D", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9922_PACKET_SIZE,
|
2012-12-19 18:01:54 +00:00
|
|
|
sr_fs9922_packet_valid, sr_fs9922_parse,
|
|
|
|
NULL,
|
|
|
|
&uni_t_ut61d_driver_info, receive_data_UNI_T_UT61D,
|
|
|
|
},
|
2013-04-29 18:23:21 +00:00
|
|
|
{
|
2014-01-06 16:20:35 +00:00
|
|
|
/* The baudrate is actually 19230, see "Note 1" below. */
|
2013-08-06 21:25:18 +00:00
|
|
|
"UNI-T", "UT61E", 19200,
|
2013-10-03 21:30:18 +00:00
|
|
|
ES519XX_14B_PACKET_SIZE,
|
|
|
|
sr_es519xx_19200_14b_packet_valid, sr_es519xx_19200_14b_parse,
|
2013-04-29 18:23:21 +00:00
|
|
|
NULL,
|
|
|
|
&uni_t_ut61e_driver_info, receive_data_UNI_T_UT61E,
|
|
|
|
},
|
2012-12-19 18:01:54 +00:00
|
|
|
{
|
2013-01-26 22:39:24 +00:00
|
|
|
"Voltcraft", "VC-820", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9721_PACKET_SIZE,
|
2012-12-19 18:01:54 +00:00
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
|
|
|
NULL,
|
|
|
|
&voltcraft_vc820_driver_info, receive_data_VOLTCRAFT_VC820,
|
|
|
|
},
|
2013-06-22 14:53:13 +00:00
|
|
|
{
|
2013-09-01 11:10:54 +00:00
|
|
|
/*
|
|
|
|
* Note: The VC830 doesn't set the 'volt' and 'diode' bits of
|
|
|
|
* the FS9922 protocol. Instead, it only sets the user-defined
|
|
|
|
* bit "z1" to indicate "diode mode" and "voltage".
|
|
|
|
*/
|
2013-06-22 14:53:13 +00:00
|
|
|
"Voltcraft", "VC-830", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9922_PACKET_SIZE,
|
2013-06-22 14:53:13 +00:00
|
|
|
sr_fs9922_packet_valid, sr_fs9922_parse,
|
2013-09-01 11:10:54 +00:00
|
|
|
&sr_fs9922_z1_diode,
|
2013-06-22 14:53:13 +00:00
|
|
|
&voltcraft_vc830_driver_info, receive_data_VOLTCRAFT_VC830,
|
|
|
|
},
|
2013-04-30 18:27:04 +00:00
|
|
|
{
|
|
|
|
"Voltcraft", "VC-840", 2400,
|
2013-11-13 21:43:26 +00:00
|
|
|
FS9721_PACKET_SIZE,
|
2013-04-30 18:27:04 +00:00
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
2013-05-01 00:10:56 +00:00
|
|
|
sr_fs9721_00_temp_c,
|
2013-04-30 18:27:04 +00:00
|
|
|
&voltcraft_vc840_driver_info, receive_data_VOLTCRAFT_VC840,
|
|
|
|
},
|
2013-11-23 11:50:33 +00:00
|
|
|
{
|
|
|
|
"Tenma", "72-7745", 2400,
|
|
|
|
FS9721_PACKET_SIZE,
|
|
|
|
sr_fs9721_packet_valid, sr_fs9721_parse,
|
|
|
|
sr_fs9721_00_temp_c,
|
2014-01-06 16:20:35 +00:00
|
|
|
&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,
|
2013-11-23 11:50:33 +00:00
|
|
|
},
|
2012-12-19 18:01:54 +00:00
|
|
|
};
|
2012-10-30 13:23:05 +00:00
|
|
|
|
2014-01-06 16:20:35 +00:00
|
|
|
/*
|
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
|
2013-05-31 14:09:57 +00:00
|
|
|
static int dev_clear(int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2013-05-10 16:59:46 +00:00
|
|
|
return std_dev_clear(udmms[dmm].di, NULL);
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int init(struct sr_context *sr_ctx, int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2012-12-19 18:01:54 +00:00
|
|
|
sr_dbg("Selected '%s' subdriver.", udmms[dmm].di->name);
|
2012-10-30 13:23:05 +00:00
|
|
|
|
2013-05-31 13:46:57 +00:00
|
|
|
return std_init(sr_ctx, udmms[dmm].di, LOG_PREFIX);
|
2012-10-30 12:11:27 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static GSList *scan(GSList *options, int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2013-01-20 18:55:33 +00:00
|
|
|
GSList *usb_devices, *devices, *l;
|
2012-10-27 20:41:50 +00:00
|
|
|
struct sr_dev_inst *sdi;
|
2012-11-02 22:44:09 +00:00
|
|
|
struct dev_context *devc;
|
2012-10-27 20:41:50 +00:00
|
|
|
struct drv_context *drvc;
|
2013-01-20 18:55:33 +00:00
|
|
|
struct sr_usb_dev_inst *usb;
|
2013-01-21 22:40:09 +00:00
|
|
|
struct sr_config *src;
|
2014-03-24 20:34:20 +00:00
|
|
|
struct sr_channel *ch;
|
2013-01-20 18:55:33 +00:00
|
|
|
const char *conn;
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2012-12-19 18:01:54 +00:00
|
|
|
drvc = udmms[dmm].di->priv;
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2013-01-20 18:55:33 +00:00
|
|
|
conn = NULL;
|
|
|
|
for (l = options; l; l = l->next) {
|
2013-01-21 22:40:09 +00:00
|
|
|
src = l->data;
|
|
|
|
switch (src->key) {
|
|
|
|
case SR_CONF_CONN:
|
2013-03-31 19:28:33 +00:00
|
|
|
conn = g_variant_get_string(src->data, NULL);
|
2013-01-20 18:55:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!conn)
|
2013-08-11 08:52:43 +00:00
|
|
|
return NULL;
|
2012-11-02 22:44:09 +00:00
|
|
|
|
2013-01-20 18:55:33 +00:00
|
|
|
devices = NULL;
|
|
|
|
if (!(usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, conn))) {
|
|
|
|
g_slist_free_full(usb_devices, g_free);
|
2012-10-27 20:41:50 +00:00
|
|
|
return NULL;
|
2013-01-20 18:55:33 +00:00
|
|
|
}
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2013-01-20 18:55:33 +00:00
|
|
|
for (l = usb_devices; l; l = l->next) {
|
|
|
|
usb = l->data;
|
2012-11-02 22:44:09 +00:00
|
|
|
|
|
|
|
if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
|
|
|
|
sr_err("Device context malloc failed.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-26 22:39:24 +00:00
|
|
|
devc->first_run = TRUE;
|
|
|
|
|
2013-01-20 18:55:33 +00:00
|
|
|
if (!(sdi = sr_dev_inst_new(0, SR_ST_INACTIVE,
|
2012-12-19 18:01:54 +00:00
|
|
|
udmms[dmm].vendor, udmms[dmm].device, NULL))) {
|
2012-11-02 22:44:09 +00:00
|
|
|
sr_err("sr_dev_inst_new returned NULL.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
sdi->priv = devc;
|
2012-12-19 18:01:54 +00:00
|
|
|
sdi->driver = udmms[dmm].di;
|
2014-03-24 20:34:20 +00:00
|
|
|
if (!(ch = sr_probe_new(0, SR_PROBE_ANALOG, TRUE, "P1")))
|
2012-11-02 22:44:09 +00:00
|
|
|
return NULL;
|
2014-03-24 20:34:20 +00:00
|
|
|
sdi->channels = g_slist_append(sdi->channels, ch);
|
2013-01-20 18:55:33 +00:00
|
|
|
|
2013-04-28 06:13:15 +00:00
|
|
|
sdi->inst_type = SR_INST_USB;
|
|
|
|
sdi->conn = usb;
|
2013-01-20 18:55:33 +00:00
|
|
|
|
|
|
|
drvc->instances = g_slist_append(drvc->instances, sdi);
|
2012-11-02 22:44:09 +00:00
|
|
|
devices = g_slist_append(devices, sdi);
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static GSList *dev_list(int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2013-01-26 22:39:24 +00:00
|
|
|
return ((struct drv_context *)(udmms[dmm].di->priv))->instances;
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_open(struct sr_dev_inst *sdi, int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2013-01-20 18:55:33 +00:00
|
|
|
struct drv_context *drvc;
|
2013-04-28 06:13:15 +00:00
|
|
|
struct sr_usb_dev_inst *usb;
|
2013-01-26 22:39:24 +00:00
|
|
|
int ret;
|
2012-11-02 22:44:09 +00:00
|
|
|
|
2012-12-19 18:01:54 +00:00
|
|
|
drvc = udmms[dmm].di->priv;
|
2013-04-28 06:13:15 +00:00
|
|
|
usb = sdi->conn;
|
2012-11-02 22:44:09 +00:00
|
|
|
|
2013-04-28 06:13:15 +00:00
|
|
|
if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) == SR_OK)
|
2013-01-26 22:39:24 +00:00
|
|
|
sdi->status = SR_ST_ACTIVE;
|
2013-04-23 13:14:42 +00:00
|
|
|
|
2013-01-26 22:39:24 +00:00
|
|
|
return ret;
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_close(struct sr_dev_inst *sdi)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
(void)sdi;
|
|
|
|
|
|
|
|
/* TODO */
|
|
|
|
|
2013-01-26 22:39:24 +00:00
|
|
|
sdi->status = SR_ST_INACTIVE;
|
2013-04-23 13:14:42 +00:00
|
|
|
|
2012-10-27 20:41:50 +00:00
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int cleanup(int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
2013-05-31 14:09:57 +00:00
|
|
|
return dev_clear(dmm);
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
2013-04-20 00:00:49 +00:00
|
|
|
static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
struct dev_context *devc;
|
|
|
|
|
2014-03-20 20:58:01 +00:00
|
|
|
(void)cg;
|
2013-04-20 00:00:49 +00:00
|
|
|
|
2012-10-27 20:41:50 +00:00
|
|
|
devc = sdi->priv;
|
|
|
|
|
2013-01-24 18:19:09 +00:00
|
|
|
switch (id) {
|
2013-01-21 22:22:47 +00:00
|
|
|
case SR_CONF_LIMIT_MSEC:
|
2013-03-31 19:28:33 +00:00
|
|
|
if (g_variant_get_uint64(data) == 0) {
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_err("Time limit cannot be 0.");
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
2013-03-31 19:28:33 +00:00
|
|
|
devc->limit_msec = g_variant_get_uint64(data);
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_dbg("Setting time limit to %" PRIu64 "ms.",
|
|
|
|
devc->limit_msec);
|
|
|
|
break;
|
2013-01-21 22:22:47 +00:00
|
|
|
case SR_CONF_LIMIT_SAMPLES:
|
2013-03-31 19:28:33 +00:00
|
|
|
if (g_variant_get_uint64(data) == 0) {
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_err("Sample limit cannot be 0.");
|
|
|
|
return SR_ERR;
|
|
|
|
}
|
2013-03-31 19:28:33 +00:00
|
|
|
devc->limit_samples = g_variant_get_uint64(data);
|
2012-10-27 20:41:50 +00:00
|
|
|
sr_dbg("Setting sample limit to %" PRIu64 ".",
|
|
|
|
devc->limit_samples);
|
|
|
|
break;
|
|
|
|
default:
|
2013-04-16 00:33:03 +00:00
|
|
|
return SR_ERR_NA;
|
2012-10-27 20:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-20 00:00:49 +00:00
|
|
|
static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
|
2014-03-20 20:58:01 +00:00
|
|
|
const struct sr_channel_group *cg)
|
2013-01-25 01:32:05 +00:00
|
|
|
{
|
|
|
|
(void)sdi;
|
2014-03-20 20:58:01 +00:00
|
|
|
(void)cg;
|
2013-01-25 01:32:05 +00:00
|
|
|
|
|
|
|
switch (key) {
|
2013-01-25 14:09:20 +00:00
|
|
|
case SR_CONF_SCAN_OPTIONS:
|
2013-03-31 19:28:33 +00:00
|
|
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
|
|
|
hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
|
2013-01-25 14:09:20 +00:00
|
|
|
break;
|
2013-01-25 14:01:49 +00:00
|
|
|
case SR_CONF_DEVICE_OPTIONS:
|
2013-03-31 19:28:33 +00:00
|
|
|
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
|
|
|
hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
|
2013-01-25 14:01:49 +00:00
|
|
|
break;
|
2013-01-25 01:32:05 +00:00
|
|
|
default:
|
2013-04-16 00:33:03 +00:00
|
|
|
return SR_ERR_NA;
|
2013-01-25 01:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
2012-12-19 18:01:54 +00:00
|
|
|
void *cb_data, int dmm)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
struct dev_context *devc;
|
|
|
|
|
|
|
|
devc = sdi->priv;
|
|
|
|
|
|
|
|
devc->cb_data = cb_data;
|
|
|
|
|
2013-05-03 22:07:34 +00:00
|
|
|
devc->starttime = g_get_monotonic_time();
|
|
|
|
|
2012-10-27 20:41:50 +00:00
|
|
|
/* Send header packet to the session bus. */
|
2013-05-03 19:59:32 +00:00
|
|
|
std_session_send_df_header(cb_data, LOG_PREFIX);
|
2012-10-27 20:41:50 +00:00
|
|
|
|
2012-12-19 18:01:54 +00:00
|
|
|
sr_source_add(0, 0, 10 /* poll_timeout */,
|
|
|
|
udmms[dmm].receive_data, (void *)sdi);
|
2012-10-27 20:41:50 +00:00
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
2012-10-27 20:41:50 +00:00
|
|
|
{
|
|
|
|
struct sr_datafeed_packet packet;
|
|
|
|
|
|
|
|
(void)sdi;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* TODO? */
|
|
|
|
sr_source_remove(0);
|
|
|
|
|
|
|
|
return SR_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-19 18:01:54 +00:00
|
|
|
/* Driver-specific API function wrappers */
|
|
|
|
#define HW_INIT(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
#define HW_CLEANUP(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static int cleanup_##X(void) { return cleanup(X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
#define HW_SCAN(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static GSList *scan_##X(GSList *options) { return scan(options, X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
#define HW_DEV_LIST(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static GSList *dev_list_##X(void) { return dev_list(X); }
|
2013-05-31 14:09:57 +00:00
|
|
|
#define HW_DEV_CLEAR(X) \
|
|
|
|
static int dev_clear_##X(void) { return dev_clear(X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
#define HW_DEV_ACQUISITION_START(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
|
|
|
|
void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
#define HW_DEV_OPEN(X) \
|
2013-05-10 17:37:54 +00:00
|
|
|
static int dev_open_##X(struct sr_dev_inst *sdi) { return dev_open(sdi, X); }
|
2012-12-19 18:01:54 +00:00
|
|
|
|
|
|
|
/* Driver structs and API function wrappers */
|
|
|
|
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
|
|
|
|
HW_INIT(ID_UPPER) \
|
|
|
|
HW_CLEANUP(ID_UPPER) \
|
|
|
|
HW_SCAN(ID_UPPER) \
|
|
|
|
HW_DEV_LIST(ID_UPPER) \
|
2013-05-31 14:09:57 +00:00
|
|
|
HW_DEV_CLEAR(ID_UPPER) \
|
2012-12-19 18:01:54 +00:00
|
|
|
HW_DEV_ACQUISITION_START(ID_UPPER) \
|
|
|
|
HW_DEV_OPEN(ID_UPPER) \
|
|
|
|
SR_PRIV struct sr_dev_driver ID##_driver_info = { \
|
|
|
|
.name = NAME, \
|
|
|
|
.longname = LONGNAME, \
|
|
|
|
.api_version = 1, \
|
2013-05-10 17:37:54 +00:00
|
|
|
.init = init_##ID_UPPER, \
|
|
|
|
.cleanup = cleanup_##ID_UPPER, \
|
|
|
|
.scan = scan_##ID_UPPER, \
|
|
|
|
.dev_list = dev_list_##ID_UPPER, \
|
2013-05-31 14:09:57 +00:00
|
|
|
.dev_clear = dev_clear_##ID_UPPER, \
|
2012-12-19 18:01:54 +00:00
|
|
|
.config_get = NULL, \
|
|
|
|
.config_set = config_set, \
|
|
|
|
.config_list = config_list, \
|
2013-05-10 17:37:54 +00:00
|
|
|
.dev_open = dev_open_##ID_UPPER, \
|
|
|
|
.dev_close = dev_close, \
|
|
|
|
.dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
|
|
|
|
.dev_acquisition_stop = dev_acquisition_stop, \
|
2012-12-19 18:01:54 +00:00
|
|
|
.priv = NULL, \
|
2012-10-30 12:11:27 +00:00
|
|
|
};
|
|
|
|
|
2013-05-01 01:00:08 +00:00
|
|
|
DRV(tecpel_dmm_8061, TECPEL_DMM_8061, "tecpel-dmm-8061", "Tecpel DMM-8061")
|
2013-07-05 12:02:50 +00:00
|
|
|
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")
|
2014-01-03 21:32:16 +00:00
|
|
|
DRV(uni_t_ut60g, UNI_T_UT60G, "uni-t-ut60g", "UNI-T UT60G")
|
2014-01-01 14:25:39 +00:00
|
|
|
DRV(uni_t_ut61b, UNI_T_UT61B, "uni-t-ut61b", "UNI-T UT61B")
|
2013-12-29 16:35:51 +00:00
|
|
|
DRV(uni_t_ut61c, UNI_T_UT61C, "uni-t-ut61c", "UNI-T UT61C")
|
2012-12-19 18:01:54 +00:00
|
|
|
DRV(uni_t_ut61d, UNI_T_UT61D, "uni-t-ut61d", "UNI-T UT61D")
|
2013-04-29 18:23:21 +00:00
|
|
|
DRV(uni_t_ut61e, UNI_T_UT61E, "uni-t-ut61e", "UNI-T UT61E")
|
2012-12-19 18:01:54 +00:00
|
|
|
DRV(voltcraft_vc820, VOLTCRAFT_VC820, "voltcraft-vc820", "Voltcraft VC-820")
|
2013-06-22 14:53:13 +00:00
|
|
|
DRV(voltcraft_vc830, VOLTCRAFT_VC830, "voltcraft-vc830", "Voltcraft VC-830")
|
2013-04-30 18:27:04 +00:00
|
|
|
DRV(voltcraft_vc840, VOLTCRAFT_VC840, "voltcraft-vc840", "Voltcraft VC-840")
|
2013-11-23 11:50:33 +00:00
|
|
|
DRV(tenma_72_7745, TENMA_72_7745, "tenma-72-7745", "Tenma 72-7745")
|
2014-01-06 16:20:35 +00:00
|
|
|
DRV(tenma_72_7750, TENMA_72_7750, "tenma-72-7750", "Tenma 72-7750")
|