]> sigrok.org Git - libsigrok.git/blob - src/hardware/serial-lcr/protocol.h
8e11733c423e4ae44d8f37afbc26a57b9ac17a8c
[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 *comm;
37         size_t packet_size;
38         gboolean (*packet_valid)(const uint8_t *pkt);
39         int (*packet_parse)(const uint8_t *pkt, float *value,
40                 struct sr_datafeed_analog *analog, void *info);
41         int (*config_get)(uint32_t key, GVariant **data,
42                 const struct sr_dev_inst *sdi,
43                 const struct sr_channel_group *cg);
44         int (*config_set)(uint32_t key, GVariant *data,
45                 const struct sr_dev_inst *sdi,
46                 const struct sr_channel_group *cg);
47         int (*config_list)(uint32_t key, GVariant **data,
48                 const struct sr_dev_inst *sdi,
49                 const struct sr_channel_group *cg);
50 };
51
52 #define LCR_BUFSIZE     128
53
54 struct dev_context {
55         const struct lcr_info *lcr_info;
56         struct sr_sw_limits limits;
57         uint8_t buf[LCR_BUFSIZE];
58         size_t buf_rxpos, buf_rdpos;
59         struct lcr_parse_info parse_info;
60         uint64_t output_freq;
61         const char *circuit_model;
62 };
63
64 SR_PRIV int lcr_receive_data(int fd, int revents, void *cb_data);
65
66 #endif