X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fserial-lcr%2Fprotocol.h;fp=src%2Fhardware%2Fserial-lcr%2Fprotocol.h;h=4a6e7f043f840c4e95db50d67bd401bd8fd642b2;hb=e4204b1757459a03c0a70849a659f27387edc295;hp=0000000000000000000000000000000000000000;hpb=8686b747cd40695c36f998603f6e853ee5eea883;p=libsigrok.git diff --git a/src/hardware/serial-lcr/protocol.h b/src/hardware/serial-lcr/protocol.h new file mode 100644 index 00000000..4a6e7f04 --- /dev/null +++ b/src/hardware/serial-lcr/protocol.h @@ -0,0 +1,70 @@ +/* + * This file is part of the libsigrok project. + * + * Copyright (C) 2014 Janne Huttunen + * Copyright (C) 2019 Gerhard Sittig + * + * 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 3 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, see . + */ + +#ifndef LIBSIGROK_HARDWARE_SERIAL_LCR_PROTOCOL_H +#define LIBSIGROK_HARDWARE_SERIAL_LCR_PROTOCOL_H + +#define LOG_PREFIX "serial-lcr" + +#include +#include +#include +#include + +struct lcr_info { + struct sr_dev_driver di; + const char *vendor; + const char *model; + size_t channel_count; + const char **channel_formats; + const char *comm; + size_t packet_size; + int64_t req_timeout_ms; + int (*packet_request)(struct sr_serial_dev_inst *serial); + gboolean (*packet_valid)(const uint8_t *pkt); + int (*packet_parse)(const uint8_t *pkt, float *value, + struct sr_datafeed_analog *analog, void *info); + int (*config_get)(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg); + int (*config_set)(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg); + int (*config_list)(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, + const struct sr_channel_group *cg); +}; + +#define LCR_BUFSIZE 128 + +struct dev_context { + const struct lcr_info *lcr_info; + struct sr_sw_limits limits; + uint8_t buf[LCR_BUFSIZE]; + size_t buf_rxpos, buf_rdpos; + struct lcr_parse_info parse_info; + uint64_t output_freq; + const char *circuit_model; + int64_t req_next_at; +}; + +SR_PRIV int lcr_receive_data(int fd, int revents, void *cb_data); + +#endif