SR_PRIV int serial_close(struct sr_serial_dev_inst *serial);
SR_PRIV int serial_flush(struct sr_serial_dev_inst *serial);
SR_PRIV int serial_drain(struct sr_serial_dev_inst *serial);
+SR_PRIV size_t serial_has_receive_data(struct sr_serial_dev_inst *serial);
SR_PRIV int serial_write_blocking(struct sr_serial_dev_inst *serial,
const void *buf, size_t count, unsigned int timeout_ms);
SR_PRIV int serial_write_nonblocking(struct sr_serial_dev_inst *serial,
uint16_t vendor_id, uint16_t product_id);
SR_PRIV int sr_ser_libsp_get_frame_format(struct sr_serial_dev_inst *serial,
int *baud, int *bits);
+SR_PRIV size_t sr_ser_libsp_get_rx_avail(struct sr_serial_dev_inst *serial);
#endif
/*--- ezusb.c ---------------------------------------------------------------*/
return sr_ser_libsp_drain(serial);
}
+/**
+ * Check for available receive data.
+ *
+ * @param[in] serial Previously opened serial port instance.
+ *
+ * @returns The number of (known) available RX data bytes.
+ *
+ * Returns 0 if no receive data is available, or if the amount of
+ * available receive data cannot get determined.
+ */
+SR_PRIV size_t serial_has_receive_data(struct sr_serial_dev_inst *serial)
+{
+ return sr_ser_libsp_get_rx_avail(serial);
+}
+
static int _serial_write(struct sr_serial_dev_inst *serial,
const void *buf, size_t count,
int nonblocking, unsigned int timeout_ms)
return ret;
}
+
+SR_PRIV size_t sr_ser_libsp_get_rx_avail(struct sr_serial_dev_inst *serial)
+{
+ int rc;
+
+ if (!serial)
+ return 0;
+
+ rc = sp_input_waiting(serial->sp_data);
+ if (rc < 0)
+ return 0;
+
+ return rc;
+}