An mbed wrapper around the helium-client to communicate with the Helium Atom

Embed: (wiki syntax)

« Back to documentation index

BufferedSerial Class Reference

BufferedSerial Class Reference

Implements a buffered serial port. More...

#include <BufferedSerial.h>

Public Member Functions

 BufferedSerial (PinName tx, PinName rx, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
 Crete a buffered serial port.
 ~BufferedSerial ()
 Destructor.
void baud (int baud)
 Sets the baud rate for the serial port.
int getc ()
 Get a byte from the serial port buffer.
int putc (int ch)
 Write a byte to the serial port.
int readable ()
 Check if there are bytes to read.

Detailed Description

Implements a buffered serial port.

This is a simple buffered serial port to work around `readable` issues on a number of mbed implementations. Receiving on the serial port is buffered through an interrupt handler.

Note that writing is not buffered at this time since writing to the serial port at speed had not been an issue so far.

Definition at line 24 of file BufferedSerial.h.


Constructor & Destructor Documentation

BufferedSerial ( PinName  tx,
PinName  rx,
int  baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 
)

Crete a buffered serial port.

Parameters:
txSerial port tx pin to use
rxSerial port rx pin to use
baudThe baud rate to use. Defaults to the default for the current board

Definition at line 8 of file BufferedSerial.cpp.

Destructor.

Definition at line 18 of file BufferedSerial.cpp.


Member Function Documentation

void baud ( int  baud )

Sets the baud rate for the serial port.

Parameters:
baudThe baud rate to set on the serial port

Definition at line 29 of file BufferedSerial.cpp.

int getc (  )

Get a byte from the serial port buffer.

Returns:
a buffered byte or -1 if no bytes are available

Definition at line 34 of file BufferedSerial.cpp.

int putc ( int  ch )

Write a byte to the serial port.

Parameters:
chThe byte to write
Returns:
the byte that was written

Definition at line 44 of file BufferedSerial.cpp.

int readable (  )

Check if there are bytes to read.

Returns:
1 if bytes are available, 0 otherwise

Definition at line 51 of file BufferedSerial.cpp.