A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Embed: (wiki syntax)

« Back to documentation index

MTSSerialFlowControl Class Reference

MTSSerialFlowControl Class Reference

This class derives from MTSBufferedIO/MTSSerial and provides a buffered wrapper to the standard mbed Serial class along with generic RTS/CTS HW flow control. More...

#include <MTSSerialFlowControl.h>

Inherits mts::MTSSerial.

Public Member Functions

 MTSSerialFlowControl (PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize=64, int rxBufSize=64)
 Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial port through internal SW buffers.
 ~MTSSerialFlowControl ()
 Destructs an MTSSerialFlowControl object and frees all related resources, including internal buffers.
virtual void rxClear ()
 This method clears all the data from the internal Rx or read buffer.
void baud (int baudrate)
 This method is used to the set the baud rate of the serial port.
void format (int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1)
 This method sets the transmission format used by the serial port.
int write (const char *data, int length, unsigned int timeoutMillis)
 This method enables bulk writes to the Tx or write buffer.
int write (const char *data, int length)
 This method enables bulk writes to the Tx or write buffer.
int write (char data, unsigned int timeoutMillis)
 This method attempts to write a single byte to the tx buffer within the timeout period.
int write (char data)
 This method writes a signle byte as a char to the Tx or write buffer.
int writeable ()
 This method is used to get the space available to write bytes to the Tx buffer.
int read (char *data, int length, unsigned int timeoutMillis)
 This method enables bulk reads from the Rx or read buffer.
int read (char *data, int length)
 This method enables bulk reads from the Rx or read buffer.
int read (char &data, unsigned int timeoutMillis)
 This method reads a single byte from the Rx or read buffer.
int read (char &data)
 This method reads a single byte from the Rx or read buffer.
int readable ()
 This method is used to get the number of bytes available to read from the Rx or read buffer.
bool txEmpty ()
 This method determines if the Tx or write buffer is empty.
bool rxEmpty ()
 This method determines if the Rx or read buffer is empty.
bool txFull ()
 This method determines if the Tx or write buffer is full.
bool rxFull ()
 This method determines if the Rx or read buffer is full.
virtual void txClear ()
 This method clears all the data from the internal Tx or write buffer.

Detailed Description

This class derives from MTSBufferedIO/MTSSerial and provides a buffered wrapper to the standard mbed Serial class along with generic RTS/CTS HW flow control.

Since it depends only on the mbed Serial, DigitalOut and InterruptIn classes for accessing the serial data, this class is inherently portable accross different mbed platforms and provides HW flow control even when not natively supported by the processors serial port. If HW flow control is not needed, use MTSSerial instead. It should also be noted that the RTS/CTS functionality in this class is implemented as a DTE device.

Definition at line 35 of file MTSSerialFlowControl.h.


Constructor & Destructor Documentation

MTSSerialFlowControl ( PinName  TXD,
PinName  RXD,
PinName  RTS,
PinName  CTS,
int  txBufSize = 64,
int  rxBufSize = 64 
)

Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial port through internal SW buffers.

Note that this class also adds the ability to use RTS/CTS HW Flow Conrtol through and standard mbed DigitalIn and DigitalOut pins. The RTS and CTS functionality assumes this is a DTE device.

Parameters:
TXDthe transmit data pin on the desired mbed serial interface.
RXDthe receive data pin on the desired mbed serial interface.
RTSthe DigitalOut pin that RTS will be attached to. (DTE)
CTSthe DigitalIn pin that CTS will be attached to. (DTE)
txBufferSizethe size in bytes of the internal SW transmit buffer. The default is 64 bytes.
rxBufferSizethe size in bytes of the internal SW receive buffer. The default is 64 bytes.
namean optional name for the serial port. The default is blank.

Definition at line 21 of file MTSSerialFlowControl.cpp.

Destructs an MTSSerialFlowControl object and frees all related resources, including internal buffers.

Definition at line 35 of file MTSSerialFlowControl.cpp.


Member Function Documentation

void baud ( int  baudrate ) [inherited]

This method is used to the set the baud rate of the serial port.

Parameters:
baudratethe baudrate in bps as an int. The default is 9600 bps.

Definition at line 34 of file MTSSerial.cpp.

void format ( int  bits = 8,
SerialBase::Parity  parity = mbed::SerialBase::None,
int  stop_bits = 1 
) [inherited]

This method sets the transmission format used by the serial port.

Parameters:
bitsthe number of bits in a word (5-8; default = 8)
paritythe parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
stopthe number of stop bits (1 or 2; default = 1)

Definition at line 39 of file MTSSerial.cpp.

int read ( char *  data,
int  length,
unsigned int  timeoutMillis 
) [inherited]

This method enables bulk reads from the Rx or read buffer.

If more data is requested then available it simply returns all remaining data within the buffer.

Parameters:
datathe buffer where data read will be added to.
lengththe amount of data in bytes to be read into the buffer. amount of time to complete operation.
Returns:
the total number of bytes that were read.

Definition at line 81 of file MTSBufferedIO.cpp.

int read ( char *  data,
int  length 
) [inherited]

This method enables bulk reads from the Rx or read buffer.

If more data is requested then available it simply returns all remaining data within the buffer.

Parameters:
datathe buffer where data read will be added to.
lengththe amount of data in bytes to be read into the buffer.
Returns:
the total number of bytes that were read.

Definition at line 93 of file MTSBufferedIO.cpp.

int read ( char &  data,
unsigned int  timeoutMillis 
) [inherited]

This method reads a single byte from the Rx or read buffer.

Parameters:
datachar where the read byte will be stored. amount of time to complete operation.
Returns:
1 if byte is read or 0 if no byte is available.

Definition at line 103 of file MTSBufferedIO.cpp.

int read ( char &  data ) [inherited]

This method reads a single byte from the Rx or read buffer.

Parameters:
datachar where the read byte will be stored.
Returns:
1 if byte is read or 0 if no byte is available.

Definition at line 108 of file MTSBufferedIO.cpp.

int readable (  ) [inherited]

This method is used to get the number of bytes available to read from the Rx or read buffer.

Returns:
the number of bytes available, 0 if there are no bytes to read.

Definition at line 113 of file MTSBufferedIO.cpp.

void rxClear (  ) [virtual]

This method clears all the data from the internal Rx or read buffer.

Reimplemented from MTSBufferedIO.

Definition at line 40 of file MTSSerialFlowControl.cpp.

bool rxEmpty (  ) [inherited]

This method determines if the Rx or read buffer is empty.

Returns:
true if empty, otherwise false.

Definition at line 122 of file MTSBufferedIO.cpp.

bool rxFull (  ) [inherited]

This method determines if the Rx or read buffer is full.

Returns:
true if full, otherwise false.

Definition at line 132 of file MTSBufferedIO.cpp.

void txClear (  ) [virtual, inherited]

This method clears all the data from the internal Tx or write buffer.

Definition at line 137 of file MTSBufferedIO.cpp.

bool txEmpty (  ) [inherited]

This method determines if the Tx or write buffer is empty.

Returns:
true if empty, otherwise false.

Definition at line 117 of file MTSBufferedIO.cpp.

bool txFull (  ) [inherited]

This method determines if the Tx or write buffer is full.

Returns:
true if full, otherwise false.

Definition at line 127 of file MTSBufferedIO.cpp.

int write ( const char *  data,
int  length,
unsigned int  timeoutMillis 
) [inherited]

This method enables bulk writes to the Tx or write buffer.

If more data is requested to be written then space available the method writes as much data as possible within the timeout period and returns the actual amount written.

Parameters:
datathe byte array to be written.
lengththe length of data to be written from the data parameter. amount of time in milliseconds to complete operation.
Returns:
the number of bytes written to the buffer, which is 0 if the buffer is full.

Definition at line 33 of file MTSBufferedIO.cpp.

int write ( const char *  data,
int  length 
) [inherited]

This method enables bulk writes to the Tx or write buffer.

If more data is requested to be written then space available the method writes as much data as possible and returns the actual amount written.

Parameters:
datathe byte array to be written.
lengththe length of data to be written from the data parameter.
Returns:
the number of bytes written to the buffer, which is 0 if the buffer is full.

Definition at line 52 of file MTSBufferedIO.cpp.

int write ( char  data,
unsigned int  timeoutMillis 
) [inherited]

This method attempts to write a single byte to the tx buffer within the timeout period.

Parameters:
datathe byte to be written as a char. amount of time in milliseconds to complete operation.
Returns:
1 if the byte was written or 0 if the buffer was full.

Definition at line 67 of file MTSBufferedIO.cpp.

int write ( char  data ) [inherited]

This method writes a signle byte as a char to the Tx or write buffer.

Parameters:
datathe byte to be written as a char.
Returns:
1 if the byte was written or 0 if the buffer was full.

Definition at line 72 of file MTSBufferedIO.cpp.

int writeable (  ) [inherited]

This method is used to get the space available to write bytes to the Tx buffer.

Returns:
the number of bytes that can be written, 0 if the buffer is full.

Definition at line 77 of file MTSBufferedIO.cpp.