Bulk Transfer Stream over ttyUSBn serial connection using File Descriptors. More...
#include <sw/host/tests/usbdev/usbdev_stream/usbdev_serial.h>
Public Member Functions | |
USBDevSerial (unsigned id, uint32_t transfer_bytes, bool retrieve, bool check, bool send, bool verbose) | |
bool | Open (const char *in_name, const char *out_name) |
Open the input and output ports to the board/device for this stream. More... | |
virtual void | Stop () |
Finalize the stream, prior to shutting down. | |
virtual void | Pause () |
Pause the stream, prior to suspending the device. | |
virtual bool | Resume () |
Resume stremaing. | |
virtual std::string | Report (bool status=false, bool verbose=false) const |
Return a summary report of the stream settings or status. More... | |
virtual bool | Service () |
Service this serial stream. More... | |
![]() | |
USBDevStream (unsigned id, uint32_t num_bytes, bool retrieve, bool check, bool send, bool verbose) | |
void | SetClosing (bool closing) |
Record whether or not the stream is in the process of closing (shutting down or suspending). More... | |
bool | CanSchedule () const |
Indicate whether an additional I/O transfer may safely be scheduled on this stream, eg. More... | |
unsigned | ID () const |
Return the Stream IDentifier of this stream. | |
std::string | PrefixID () |
Return a Stream IDentifier prefix suitable for logging/reporting. | |
void | SetProperties (unsigned id, bool retrieve, bool check, bool send) |
Set Stream IDentifier and flags. | |
virtual bool | Completed () const |
Indicates whether this stream has completed its transfer. More... | |
uint32_t | TransferBytes () const |
Returns the total number of bytes to be transferred by this stream. More... | |
uint32_t | BytesRecvd () const |
Returns a count of the number of bytes received from the device. More... | |
uint32_t | BytesSent () const |
Returns a count of the number of bytes sent to the device. More... | |
Additional Inherited Members | |
![]() | |
enum | StreamType { StreamType_Serial , StreamType_Bulk , StreamType_Interrupt , StreamType_Isochronous , StreamType_Control } |
Stream implementations. | |
![]() | |
static const char * | StreamTypeName (StreamType type) |
Return the textual name of the given stream type. More... | |
![]() | |
enum | sig_state_t { kSigStateStart = 0 , kSigStateCheckHead , kSigStateSkipBody , kSigStateCheckTail , kSigStateReceived } |
States in reception of signature. | |
![]() | |
bool | ProvisionSpace (uint8_t **space, uint32_t len) |
Provision the given number of bytes of contiguous space, and optionally a pointer to the start of the free space. More... | |
uint32_t | SpaceAvailable (uint8_t **space) |
Returns the amount of contiguous free space available in the buffer, and optionally a pointer to the start of the free space. More... | |
bool | AddData (const uint8_t *data, uint32_t len) |
Add the specified number of bytes to the circular buffer; if data is NULL then the bytes shall already be present in the buffer and copying is not performed. More... | |
bool | CommitData (uint32_t len) |
Record that the specified number of bytes have been added to the circular buffer. More... | |
void | ClearBuffer () |
CLear the circular buffer by removing all of its contained data bytes. More... | |
void | SigReset () |
Reset the signature detection; Isochronous streams including a new signature at the start of each packet transferred. | |
bool | SigReceived () const |
Has valid signature been received on this stream? Note that there may be some additional validity checks required for specific= transfer types. More... | |
void | SigProcess (const usbdev_stream_sig_t &sig) |
Collect stream flags from the supplied signature. More... | |
uint32_t | SigDetect (usbdev_stream_sig_t *sig, const uint8_t *sp, uint32_t nrecv) |
Detect and parse stream/packet signature, returning a count of the number of bytes to be discarded from the start of this data. More... | |
void | SigReport (const usbdev_stream_sig_t &sig) |
Diagnostic utility function to report the contents of a stream/packet signature. More... | |
void | GenerateData (uint8_t *dp, uint32_t len) |
Generate a sequence of bytes as if we'd received them correctly from the device. | |
bool | ProcessData (uint8_t *dp, uint32_t len) |
Process the given sequence of bytes according to the current stream state. | |
uint32_t | DataAvailable (uint8_t **data) |
Return the number of contiguous bytes of data available in the stream buffer, and a pointer to the first byte of data. More... | |
bool | DiscardData (uint32_t len) |
Update the stream buffer to indicate that data has been discarded (removed from the buffer but not sent to the USB device). More... | |
bool | ConsumeData (uint32_t len) |
Update the stream buffer to indicate that data has been consumed. More... | |
uint8_t | sig_read8 (size_t offset) |
uint16_t | sig_read16 (size_t offset) |
uint32_t | sig_read32 (size_t offset) |
![]() | |
unsigned | id_ |
Stream IDentifier. | |
bool | closing_ |
Is the stream being closed? | |
sig_state_t | sig_recvd_ |
Have we received the stream signature yet? | |
unsigned | sig_cnt_ |
bool | retrieve_ |
Retrieve IN data for this stream? | |
bool | check_ |
Check the received data against expectations? | |
bool | send_ |
Send OUT data for this stream? | |
bool | verbose_ |
Verbose reporting? | |
uint32_t | bytes_recvd_ |
Total number of bytes received. | |
uint32_t | bytes_sent_ |
Total number of bytes sent. | |
uint8_t | tst_lfsr_ |
Device-side LFSR; byte stream expected from usbdev_stream_test. | |
uint8_t | dpi_lfsr_ |
Host/DPI-side LFSR. | |
uint32_t | transfer_bytes_ |
Number of bytes to be transferred. | |
struct { | |
uint32_t | wr_idx |
Offset at which to write the next received data (IN from device). | |
uint32_t | rd_idx |
Offset of next byte to be read from the buffer (OUT to device). | |
uint32_t | end_idx |
Offset beyond used portion of the buffer; for packet-based transmission we wrap before the end of the circular buffer if a maximum-length packet does not fit. | |
uint8_t | data [kBufferSize] |
Circular buffer of data being transferred from input to output port. | |
} | buf_ |
Circular buffer of streamed data. | |
![]() | |
static constexpr uint32_t | kBufferSize = 0x10000U |
Size of circular buffer used for streaming. | |
Bulk Transfer Stream over ttyUSBn serial connection using File Descriptors.
Definition at line 11 of file usbdev_serial.h.
bool USBDevSerial::Open | ( | const char * | in_name, |
const char * | out_name | ||
) |
Open the input and output ports to the board/device for this stream.
in_name | Device name of input serial port. |
out_name | Device name of output serial port. |
Definition at line 16 of file usbdev_serial.cc.
|
virtual |
Return a summary report of the stream settings or status.
status | Indicates whether settings or status requested. |
verbose | true iff a more verbose report is required. |
Implements USBDevStream.
Definition at line 69 of file usbdev_serial.cc.
|
virtual |
Service this serial stream.
Reimplemented from USBDevStream.
Definition at line 164 of file usbdev_serial.cc.