]> sigrok.org Git - libsigrok.git/blob - src/hardware/serial-lcr/protocol.h
scpi-pps: don't break SCPI devices when scanning for HP-IB devices
[libsigrok.git] / src / hardware / serial-lcr / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2014 Janne Huttunen <jahuttun@gmail.com>
5  * Copyright (C) 2019 Gerhard Sittig <gerhard.sittig@gmx.net>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef LIBSIGROK_HARDWARE_SERIAL_LCR_PROTOCOL_H
22 #define LIBSIGROK_HARDWARE_SERIAL_LCR_PROTOCOL_H
23
24 #define LOG_PREFIX "serial-lcr"
25
26 #include <libsigrok/libsigrok.h>
27 #include <libsigrok-internal.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30
31 struct lcr_info {
32         struct sr_dev_driver di;
33         const char *vendor;
34         const char *model;
35         size_t channel_count;
36         const char **channel_formats;
37         const char *comm;
38         size_t packet_size;
39         int64_t req_timeout_ms;
40         int (*packet_request)(struct sr_serial_dev_inst *serial);
41         gboolean (*packet_valid)(const uint8_t *pkt);
42         int (*packet_parse)(const uint8_t *pkt, float *value,
43                 struct sr_datafeed_analog *analog, void *info);
44         int (*config_get)(uint32_t key, GVariant **data,
45                 const struct sr_dev_inst *sdi,
46                 const struct sr_channel_group *cg);
47         int (*config_set)(uint32_t key, GVariant *data,
48                 const struct sr_dev_inst *sdi,
49                 const struct sr_channel_group *cg);
50         int (*config_list)(uint32_t key, GVariant **data,
51                 const struct sr_dev_inst *sdi,
52                 const struct sr_channel_group *cg);
53 };
54
55 #define LCR_BUFSIZE     128
56
57 struct dev_context {
58         const struct lcr_info *lcr_info;
59         struct sr_sw_limits limits;
60         uint8_t buf[LCR_BUFSIZE];
61         size_t buf_rxpos, buf_rdpos;
62         struct lcr_parse_info parse_info;
63         uint64_t output_freq;
64         const char *circuit_model;
65         int64_t req_next_at;
66 };
67
68 SR_PRIV int lcr_receive_data(int fd, int revents, void *cb_data);
69
70 #endif