User Manual

that you should almost always wait until the data has been sent before calling this function again. See
serial_send_blocking(), below, for an easy way to do this.
static void OrangutanSerial::sendBlocking([unsigned char port,] char * buffer, unsigned char size)
void serial_send_blocking([unsigned char port,] char * buffer, unsigned char size)
Same as serial_send(), but waits until transmission of the last byte has started before returning. When this
function returns, it is safe to call serial_send() or serial_send_blocking() again.
Warning: When using the Orangutan SVP’s USB_COMM port, serial_send_blocking() might
never return because the rate at which bytes can be sent to the computer is dictated by
how often the computer requests to read bytes from the Orangutan. If the Orangutan’s USB
port is not connected, or for some reason the computer has stopped reading bytes from the
Orangutan’s USB Communications port, then this function might never return. This is not a
problem for UART-based serial ports or the Orangutan X2’s USB_COMM port because the
rate of transmission is dictated only by the AVR’s code and the baud rate, so all the bytes will
finish transmitting in a relatively predictable amount of time.
static inline unsigned char OrangutanSerial::getSentBytes([unsigned char port ])
unsigned char serial_get_sent_bytes([unsigned char port ])
Returns the number of bytes that have been sent since serial_send() was called.
static char OrangutanSerial::sendBufferEmpty([unsigned char port ])
char serial_send_buffer_empty([unsigned char port ])
Returns 1 (true) when the send buffer is empty; when there are no more bytes to send. Returns 0 (false)
otherwise.
static void OrangutanSerial::setMode([unsigned char port,] unsigned char mode)
void serial_set_mode([unsigned char port,] unsigned char mode)
Sets the serial library to use either interrupts (with the argument SERIAL_AUTOMATIC) or polling
(SERIAL_CHECK). If SERIAL_CHECK is selected, your code must call serial_check() often to ensure
reliable reception and timely transmission of data. The default mode for all UART-based ports is
SERIAL_AUTOMATIC. The default and only allowed mode for the Orangutan SVP’s and Orangutan X2’s
USB_COMM port is SERIAL_CHECK.
static char OrangutanSerial::getMode([unsigned char port,] unsigned char mode)
char serial_get_mode([unsigned char port ])
Returns the current serial mode.
static void OrangutanSerial::check()
void serial_check()
Checks for any bytes to be received or transmitted (on all available ports) and performs the required action.
You only need to use this function if one of your ports is in SERIAL_CHECK mode. If all of your ports are
in SERIAL_AUTOMATIC mode, you will not need to use this function. The default and only allowed mode
for the Orangutan SVP’s and Orangutan X2’s USB_COMM port is SERIAL_CHECK, so you should call this
function often if you want to use that port.
Pololu AVR Library Command Reference © 2001–2015 Pololu Corporation
10. Orangutan Serial Port Communication Page 41 of 65