* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
+#include <glib.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
#include "protocol.h"
SR_PRIV struct sr_dev_driver pce_pce_dm32_driver_info;
SR_PRIV struct sr_dev_driver radioshack_22_168_driver_info;
SR_PRIV struct sr_dev_driver radioshack_22_812_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_vc820_ser_driver_info;
+SR_PRIV struct sr_dev_driver voltcraft_vc840_ser_driver_info;
SR_PRIV struct dmm_info dmms[] = {
{
NULL,
&radioshack_22_812_driver_info, receive_data_RADIOSHACK_22_812,
},
+ {
+ "Voltcraft", "VC-820 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
+ 2400, FS9721_PACKET_SIZE, NULL,
+ sr_fs9721_packet_valid, sr_fs9721_parse,
+ NULL,
+ &voltcraft_vc820_ser_driver_info, receive_data_VOLTCRAFT_VC820,
+ },
+ {
+ "Voltcraft", "VC-840 (UT-D02 cable)", "2400/8n1/rts=0/dtr=1",
+ 2400, FS9721_PACKET_SIZE, NULL,
+ sr_fs9721_packet_valid, sr_fs9721_parse,
+ NULL,
+ &voltcraft_vc840_ser_driver_info, receive_data_VOLTCRAFT_VC840,
+ },
};
/* Properly close and free all devices. */
if (serial_open(serial, SERIAL_RDWR | SERIAL_NONBLOCK) != SR_OK)
return NULL;
- sr_info("Probing port %s.", conn);
+ sr_info("Probing serial port %s.", conn);
drvc = dmms[dmm].di->priv;
devices = NULL;
serial_flush(serial);
- /*
- * There's no way to get an ID from the multimeter. It just sends data
- * periodically, so the best we can do is check if the packets match
- * the expected format.
- */
-
- /* Let's get a bit of data and see if we can find a packet. */
- len = sizeof(buf);
-
/* Request a packet if the DMM requires this. */
if (dmms[dmm].packet_request) {
if ((ret = dmms[dmm].packet_request(serial)) < 0) {
}
}
+ /*
+ * There's no way to get an ID from the multimeter. It just sends data
+ * periodically (or upon request), so the best we can do is check if
+ * the packets match the expected format.
+ */
+
+ /* Let's get a bit of data and see if we can find a packet. */
+ len = sizeof(buf);
ret = serial_stream_detect(serial, buf, &len, dmms[dmm].packet_size,
dmms[dmm].packet_valid, 1000,
dmms[dmm].baudrate);
* If we dropped more than two packets worth of data, something is
* wrong. We shouldn't quit however, since the dropped bytes might be
* just zeroes at the beginning of the stream. Those can occur as a
- * combination of the nonstandard cable that ships with this device and
- * the serial port or USB to serial adapter.
+ * combination of the nonstandard cable that ships with some devices
+ * and the serial port or USB to serial adapter.
*/
dropped = len - dmms[dmm].packet_size;
if (dropped > 2 * dmms[dmm].packet_size)
}
devc->serial = serial;
- devc->subdriver = dmm;
sdi->priv = devc;
sdi->driver = dmms[dmm].di;
}
static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
- void *cb_data)
+ void *cb_data, int dmm)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
/* Poll every 50ms, or whenever some data comes in. */
sr_source_add(devc->serial->fd, G_IO_IN, 50,
- dmms[devc->subdriver].receive_data, (void *)sdi);
+ dmms[dmm].receive_data, (void *)sdi);
return SR_OK;
}
static GSList *hw_dev_list_##X(void) { return hw_dev_list(X); }
#define CLEAR_INSTANCES(X) \
static int clear_instances_##X(void) { return clear_instances(X); }
+#define HW_DEV_ACQUISITION_START(X) \
+static int hw_dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
+void *cb_data) { return hw_dev_acquisition_start(sdi, cb_data, X); }
/* Driver structs and API function wrappers */
#define DRV(ID, ID_UPPER, NAME, LONGNAME) \
HW_SCAN(ID_UPPER) \
HW_DEV_LIST(ID_UPPER) \
CLEAR_INSTANCES(ID_UPPER) \
+HW_DEV_ACQUISITION_START(ID_UPPER) \
SR_PRIV struct sr_dev_driver ID##_driver_info = { \
.name = NAME, \
.longname = LONGNAME, \
.dev_close = hw_dev_close, \
.info_get = hw_info_get, \
.dev_config_set = hw_dev_config_set, \
- .dev_acquisition_start = hw_dev_acquisition_start, \
+ .dev_acquisition_start = hw_dev_acquisition_start_##ID_UPPER, \
.dev_acquisition_stop = hw_dev_acquisition_stop, \
.priv = NULL, \
};
DRV(pce_pce_dm32, PCE_PCE_DM32, "pce-pce-dm32", "PCE PCE-DM32")
DRV(radioshack_22_168, RADIOSHACK_22_168, "radioshack-22-168", "RadioShack 22-168")
DRV(radioshack_22_812, RADIOSHACK_22_812, "radioshack-22-812", "RadioShack 22-812")
+DRV(voltcraft_vc820_ser, VOLTCRAFT_VC820, "voltcraft-vc820-ser", "Voltcraft VC-820 (UT-D02 cable)")
+DRV(voltcraft_vc840_ser, VOLTCRAFT_VC840, "voltcraft-vc840-ser", "Voltcraft VC-840 (UT-D02 cable)")