Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

UnbufferedSerial class

UnbufferedSerial class
[UART]

Data Structures

class  UnbufferedSerial
 Class implementation for unbuffered I/O for an interrupt driven application or one that needs to have more control. More...

Functions

 UnbufferedSerial (const serial_pinmap_t &static_pinmap, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
 Create a UnbufferedSerial port, connected to the specified transmit and receive pins, with a particular baud rate.
virtual ssize_t write (const void *buffer, size_t size)
 Write the contents of a buffer to a file.
virtual ssize_t read (void *buffer, size_t size)
 Read the contents of a file into a buffer.
virtual off_t seek (off_t offset, int whence=SEEK_SET)
 Move the file position to a given offset from from a given location.
virtual off_t size ()
 Get the size of the file.
virtual int isatty ()
 Check if the file in an interactive terminal device.
virtual int close ()
 Close a file.
virtual short poll (short events) const
 Check for poll event flags Check the events listed in events to see if data can be read or written without blocking.
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC)
 Set the flow control type on the serial port.

Function Documentation

virtual int close (  ) [virtual, inherited]

Close a file.

Returns:
0 on success, negative error code on failure

Implements FileHandle.

Definition at line 138 of file UnbufferedSerial.h.

virtual int isatty (  ) [virtual, inherited]

Check if the file in an interactive terminal device.

Returns:
True if the file is a terminal
False if the file is not a terminal
Negative error code on failure

Reimplemented from FileHandle.

Definition at line 129 of file UnbufferedSerial.h.

short poll ( short  events ) const [virtual, inherited]

Check for poll event flags Check the events listed in events to see if data can be read or written without blocking.

Call is nonblocking - returns state of events.

Parameters:
eventsbitmask of poll events we're interested in - POLLIN/POLLOUT etc.
Returns:
bitmask of poll events that have occurred.

Reimplemented from FileHandle.

Definition at line 84 of file UnbufferedSerial.cpp.

ssize_t read ( void *  buffer,
size_t  size 
) [virtual, inherited]

Read the contents of a file into a buffer.

Blocks and reads exactly one character

Parameters:
bufferThe buffer to read in to
sizeThe number of bytes to read
Returns:
The number of bytes read

Implements FileHandle.

Definition at line 67 of file UnbufferedSerial.cpp.

virtual off_t seek ( off_t  offset,
int  whence = SEEK_SET 
) [virtual, inherited]

Move the file position to a given offset from from a given location.

Not valid for a device type FileHandle like UnbufferedSerial. In case of UnbufferedSerial, returns ESPIPE

Parameters:
offsetThe offset from whence to move to
whenceThe start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
Returns:
The new offset of the file, negative error code on failure

Implements FileHandle.

Definition at line 109 of file UnbufferedSerial.h.

void set_flow_control ( Flow  type,
PinName  flow1 = NC,
PinName  flow2 = NC 
) [inherited]

Set the flow control type on the serial port.

Parameters:
typethe flow control type (Disabled, RTS, CTS, RTSCTS)
flow1the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
flow2the second flow control pin (CTS for RTSCTS)

Reimplemented from SerialBase.

Definition at line 103 of file UnbufferedSerial.cpp.

virtual off_t size (  ) [virtual, inherited]

Get the size of the file.

Returns:
Size of the file in bytes

Reimplemented from FileHandle.

Definition at line 118 of file UnbufferedSerial.h.

UnbufferedSerial ( const serial_pinmap_t &  static_pinmap,
int  baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 
) [inherited]

Create a UnbufferedSerial port, connected to the specified transmit and receive pins, with a particular baud rate.

Parameters:
static_pinmapreference to structure which holds static pinmap
baudThe baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)

Definition at line 35 of file UnbufferedSerial.cpp.

ssize_t write ( const void *  buffer,
size_t  size 
) [virtual, inherited]

Write the contents of a buffer to a file.

Blocks until all data is written

Parameters:
bufferThe buffer to write from
sizeThe number of bytes to write
Returns:
The number of bytes written

Implements FileHandle.

Definition at line 42 of file UnbufferedSerial.cpp.