User Manual

Reference
C++ methods are shown in red.
C functions are shown in green.
static void OrangutanSerial::setBaudRate([unsigned char port,] unsigned long baud)
unsigned char serial_set_baud_rate([unsigned char port,] unsigned long baud)
Sets the baud rate on the serial port. Standard values up to 115200 should work fine; for higher speeds,
please consult the AVR documentation. This function is not needed for (and has no effect on ) the Orangutan
SVP’s USB_COMM port. It is required for setting the baud for all UART ports and for the Orangutan X2’s
USB_COMM port.
static void OrangutanSerial::receive([unsigned char port,] char * buffer, unsigned char size)
void serial_receive([unsigned char port,] char * buffer, unsigned char size)
Sets up a buffer for background reception. This function returns immediately, but data arriving at the serial
port will be copied into this buffer until size bytes have been stored.
static char OrangutanSerial::receiveBlocking([unsigned char port,] char * buffer, unsigned char size,
unsigned int timeout_ms)
char serial_receive_blocking([unsigned char port,] char * buffer, unsigned char size, unsigned int
timeout_ms)
Receives data, not returning until the buffer is full or the timeout (specified in milliseconds) has expired.
Returns 1 if the timeout occurred before the buffer filled up. Returns 0 if the buffer has been filled up. This
function is useful for simple programs and for situations in which you know exactly how many bytes to expect.
static void OrangutanSerial::receiveRing([unsigned char port,] char * buffer, unsigned char size)
void serial_receive_ring([unsigned char port,] char * buffer, unsigned char size)
Sets up a ring buffer for background reception. This is a more advanced version of serial_receive() that
is useful when you need to read in data continuously without pauses. When the buffer is filled,
serial_get_received_bytes() will reset to zero, and data will continue to be inserted at the beginning of the
buffer.
static void OrangutanSerial::cancelReceive([unsigned char port ])
void serial_cancel_receive([unsigned char port)
Stops background serial reception.
static inline unsigned char OrangutanSerial::getReceivedBytes([unsigned char port ])
unsigned char serial_get_received_bytes([unsigned char port ])
Returns the number of bytes that have been read into the buffer; this is also the index of the location at which
the next received byte will be added.
static inline char OrangutanSerial::receiveBufferFull([unsigned char port ])
char serial_receive_buffer_full([unsigned char port ])
Returns 1 (true) when the receive buffer has been filled with received bytes, so that serial reception is halted.
Returns 0 (false) otherwise. This function should not be called when receiving data into a ring buffer.
static void OrangutanSerial::send([unsigned char port,] char * buffer, unsigned char size)
void serial_send([unsigned char port,] char * buffer, unsigned char size)
Sets up a buffer for background transmission. Data from this buffer will be transmitted until size bytes
have been sent. If serial_send() is called before serial_send_buffer_empty() returns true (when transmission
of the last byte has started), the old buffer will be discarded and tramission will be cut short. This means
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
10. Orangutan Serial Port Communication Page 40 of 65