]> sigrok.org Git - libsigrok.git/blame - hardware/genericdmm/genericdmm.h
genericdmm: use vid.pid as USB conn spec
[libsigrok.git] / hardware / genericdmm / genericdmm.h
CommitLineData
ca3d84cc
BV
1/*
2 * This file is part of the sigrok project.
3 *
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
db135200
BV
21#ifndef LIBSIGROK_GENERICDMM_H
22#define LIBSIGROK_GENERICDMM_H
ca3d84cc
BV
23
24/* SR_HWCAP_CONN takes one of these: */
7356a55d 25#define DMM_CONN_USB_VIDPID "^([0-9a-z]{1,4})\\.([0-9a-z]{1,4})$"
ca3d84cc
BV
26#define DMM_CONN_USB_BUSADDR "^(\\d+)\\.(\\d+)$"
27#define DMM_CONN_SERIALPORT "^([a-z0-9/\\-_]+)$"
28
29/* SR_HWCAP_SERIALCOMM like 2400/8n1 */
30#define DMM_CONN_SERIALCOMM "^(\\d+)/(\\d)([neo])(\\d)$"
31
32enum {
33 DMM_TRANSPORT_SERIAL,
34 DMM_TRANSPORT_USBHID,
35};
36
37
38struct dev_profile {
39 char *modelid;
40 char *vendor;
41 char *model;
42 struct dmmchip *chip;
43 /* Only use when the VID:PID is really specific to a DMM. */
44 uint16_t vid;
45 uint16_t pid;
46 int transport;
47};
48
49struct context {
50 struct dev_profile *profile;
51 uint64_t limit_samples;
52 uint64_t limit_msec;
53
54 /* Opaque pointer passed in by the frontend. */
55 void *cb_data;
56
57 /* Only used for USB-connected devices. */
58 struct sr_usb_dev_inst *usb;
59
60 /* Only used for serial-connected devices. */
61 struct sr_serial_dev_inst *serial;
62 int serial_speed;
63 int serial_databits;
64 int serial_parity;
65 int serial_stopbits;
66
67 /* Runtime. */
68 uint64_t num_samples;
69
70 /* DMM chip-specific data, if needed. */
71 void *priv;
72};
73
74struct dmmchip {
75 /* Optional, called once before measurement starts. */
76 int (*init) (struct context *ctx);
77 /* Called whenever a chunk of data arrives. */
78 int (*data) (struct context *ctx, unsigned char *data);
79};
80
81
db135200 82#endif /* LIBSIGROK_GENERICDMM_H */