The class inherits from the Arduino Sream class, so functions such as println() can be used once the UART is initialized.
The Serial Wombat 4B chip has a 64 byte transmit buffer and 128 byte receive buffer. Therefore, up to 64 bytes can be sent to the SerialWombatUART at a time. Attempts to send more than that will result in the write, print, etc command blocking until space is available on the SerialWombatUART to buffer the data.
Received data is buffered on the Serial Wombat chip until it is retreived from the host.
Warning
Due to the overhead of querying and retreiving data from the SerialWombatUART, data loss is likely when receiving streams of data greater than the buffer size at higher baud rates.
To minimize this possiblity, read data frequently from the Serial Wombat chip, and set I2C frequency to 400kHz to maximize throughput (SW4B only) .
This class can Send, Receive, or both. A single instance of this class is allowed per Serial Wombat 4B chip due to the fact that it relies on the PIC16F15214's UART module, of which there is only one on the micro.
Two instances of this class can be used on the Serial Wombat 18AB chip by using the begin() call which takes a hardware indicator of 0 or 1.
A full Serial Wombat packet send / receive sequence (8 bytes in each direction) over I2C is necessary to query the status of the queues or to read or receive a byte of data.
Reads a specified number of bytes from the SerialWombatUART RX queue.
Parameters
buffer
An array into which to put received bytes
length
The maximum number of bytes to be received
Returns
the number of bytes written to buffer
This function will read bytes from the SerialWombatUART RX queue into buffer. If 'length' characters are not available to read then the value returned will be less than length.
This function queries the SerialWombatUART for avaialble TX buffer space, and sends bytes as buffer space is avaialble. If avaialable buffer space is not sufficient to send the entire array then the function will block and continue trying until the entire message has been sent to the SerialWombatUART transmit queue.
This does not check to see if space is avaialble in order to improve perfomance . This isn't an issue at high baud rates, as overhead to transmit one byte at a time allows sufficent time for queuing data to be sent by the UART. This could be a problem at very low baud rates and high I2C bus speeds.