]> sigrok.org Git - libsigrok.git/blobdiff - src/libsigrok-internal.h
serial: introduce local receive data buffer
[libsigrok.git] / src / libsigrok-internal.h
index 3ea3590ae6c5dec04ddd2e5d075f43d94f3182f5..e1623f629b0e2c675cf59386eea95d542e8bf5bb 100644 (file)
@@ -36,6 +36,7 @@
 #include <libusb.h>
 #endif
 #include <stdarg.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -723,6 +724,7 @@ struct sr_usb_dev_inst {
 };
 #endif
 
+struct sr_serial_dev_inst;
 #ifdef HAVE_SERIAL_COMM
 struct ser_lib_functions;
 struct sr_serial_dev_inst {
@@ -737,6 +739,7 @@ struct sr_serial_dev_inst {
                int parity_bits;
                int stop_bits;
        } comm_params;
+       GString *rcv_buffer;
 #ifdef HAVE_LIBSERIALPORT
        /** libserialport port handle */
        struct sp_port *sp_data;
@@ -843,6 +846,30 @@ SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb);
 #endif
 
 #ifdef HAVE_SERIAL_COMM
+#ifndef HAVE_LIBSERIALPORT
+/*
+ * Some identifiers which initially got provided by libserialport are
+ * used internally within the libsigrok serial layer's implementation,
+ * while libserialport no longer is the exclusive provider of serial
+ * communication support. Declare the identifiers here so they remain
+ * available across all build configurations.
+ */
+enum libsp_parity {
+       SP_PARITY_NONE = 0,
+       SP_PARITY_ODD = 1,
+       SP_PARITY_EVEN = 2,
+       SP_PARITY_MARK = 3,
+       SP_PARITY_SPACE = 4,
+};
+
+enum libsp_flowcontrol {
+       SP_FLOWCONTROL_NONE = 0,
+       SP_FLOWCONTROL_XONXOFF = 1,
+       SP_FLOWCONTROL_RTSCTS = 2,
+       SP_FLOWCONTROL_DTRDSR = 3,
+};
+#endif
+
 /* Serial-specific instances */
 SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port,
                const char *serialcomm);
@@ -1115,6 +1142,13 @@ SR_PRIV int serial_source_remove(struct sr_session *session,
 SR_PRIV GSList *sr_serial_find_usb(uint16_t vendor_id, uint16_t product_id);
 SR_PRIV int serial_timeout(struct sr_serial_dev_inst *port, int num_bytes);
 
+SR_PRIV void sr_ser_discard_queued_data(struct sr_serial_dev_inst *serial);
+SR_PRIV size_t sr_ser_has_queued_data(struct sr_serial_dev_inst *serial);
+SR_PRIV void sr_ser_queue_rx_data(struct sr_serial_dev_inst *serial,
+               const uint8_t *data, size_t len);
+SR_PRIV size_t sr_ser_unqueue_rx_data(struct sr_serial_dev_inst *serial,
+               uint8_t *data, size_t len);
+
 struct ser_lib_functions {
        int (*open)(struct sr_serial_dev_inst *serial, int flags);
        int (*close)(struct sr_serial_dev_inst *serial);