X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Flibsigrok-internal.h;h=e1623f629b0e2c675cf59386eea95d542e8bf5bb;hb=ad5aa993ae5f5277755ed9c6e99fd647f4fa0d7b;hp=9384bbb68692dc8dfde720e333d9a50165b20169;hpb=a7b8692ed061c5baff6620c0839db85465cd24c9;p=libsigrok.git diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 9384bbb6..e1623f62 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -26,6 +26,8 @@ #ifndef LIBSIGROK_LIBSIGROK_INTERNAL_H #define LIBSIGROK_LIBSIGROK_INTERNAL_H +#include "config.h" + #include #ifdef HAVE_LIBSERIALPORT #include @@ -34,6 +36,7 @@ #include #endif #include +#include #include #include @@ -721,7 +724,8 @@ struct sr_usb_dev_inst { }; #endif -#ifdef HAVE_LIBSERIALPORT +struct sr_serial_dev_inst; +#ifdef HAVE_SERIAL_COMM struct ser_lib_functions; struct sr_serial_dev_inst { /** Port name, e.g. '/dev/tty42'. */ @@ -735,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; @@ -840,7 +845,31 @@ SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus, SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb); #endif -#ifdef HAVE_LIBSERIALPORT +#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); @@ -957,7 +986,7 @@ SR_PRIV int std_dummy_dev_open(struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_close(struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_acquisition_start(const struct sr_dev_inst *sdi); SR_PRIV int std_dummy_dev_acquisition_stop(struct sr_dev_inst *sdi); -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi); SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi); #endif @@ -1067,7 +1096,7 @@ SR_PRIV int soft_trigger_logic_check(struct soft_trigger_logic *st, uint8_t *buf /*--- serial.c --------------------------------------------------------------*/ -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM enum { SERIAL_RDWR = 1, SERIAL_RDONLY = 2, @@ -1113,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); @@ -1385,7 +1421,7 @@ struct metex14_info { gboolean is_hfe, is_unitless, is_logic, is_min, is_max, is_avg; }; -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int sr_metex14_packet_request(struct sr_serial_dev_inst *serial); #endif SR_PRIV gboolean sr_metex14_packet_valid(const uint8_t *buf); @@ -1516,7 +1552,7 @@ struct asycii_info { gboolean is_invalid; }; -#ifdef HAVE_LIBSERIALPORT +#ifdef HAVE_SERIAL_COMM SR_PRIV int sr_asycii_packet_request(struct sr_serial_dev_inst *serial); #endif SR_PRIV gboolean sr_asycii_packet_valid(const uint8_t *buf);