X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frdtech-tc%2Fprotocol.h;h=e495375ca673dc7b46bef478fbec0c964e237be4;hb=HEAD;hp=4692ec4022f004fe223abba239050041ec21c486;hpb=63f46e3e6f1b3b0a20a1da45ad10a1cd0a8937ab;p=libsigrok.git diff --git a/src/hardware/rdtech-tc/protocol.h b/src/hardware/rdtech-tc/protocol.h index 4692ec40..e495375c 100644 --- a/src/hardware/rdtech-tc/protocol.h +++ b/src/hardware/rdtech-tc/protocol.h @@ -25,7 +25,16 @@ #define LOG_PREFIX "rdtech-tc" -#define RDTECH_TC_BUFSIZE 256 +/* + * Keep request and response buffers of sufficient size. The maximum + * request text currently involved is "bgetva\r\n" which translates + * to 9 bytes. The poll response (a measurement, the largest amount + * of data that is currently received) is 192 bytes in length. Add + * some slack for alignment, and for in-flight messages or adjacent + * data during synchronization to the data stream. + */ +#define RDTECH_TC_MAXREQLEN 12 +#define RDTECH_TC_RSPBUFSIZE 256 struct rdtech_dev_info { char *model_name; @@ -33,17 +42,31 @@ struct rdtech_dev_info { uint32_t serial_num; }; +struct rdtech_tc_channel_desc { + const char *name; + struct binary_value_spec spec; + struct sr_rational scale; + int digits; + enum sr_mq mq; + enum sr_unit unit; +}; + struct dev_context { + gboolean is_bluetooth; + char req_text[RDTECH_TC_MAXREQLEN]; struct rdtech_dev_info dev_info; - const struct binary_analog_channel *channels; + const struct rdtech_tc_channel_desc *channels; + size_t channel_count; + struct feed_queue_analog **feeds; struct sr_sw_limits limits; - uint8_t buf[RDTECH_TC_BUFSIZE]; - size_t buflen; + uint8_t buf[RDTECH_TC_RSPBUFSIZE]; + size_t rdlen; int64_t cmd_sent_at; + size_t rx_after_tx; }; SR_PRIV int rdtech_tc_probe(struct sr_serial_dev_inst *serial, struct dev_context *devc); SR_PRIV int rdtech_tc_receive_data(int fd, int revents, void *cb_data); -SR_PRIV int rdtech_tc_poll(const struct sr_dev_inst *sdi); +SR_PRIV int rdtech_tc_poll(const struct sr_dev_inst *sdi, gboolean force); #endif