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
MTSSerial Class Reference
This class derives from MTSBufferedIO and provides a buffered wrapper to the standard mbed Serial class. More...
#include <MTSSerial.h>
Inherits mts::MTSBufferedIO.
Inherited by MTSSerialFlowControl.
Public Member Functions | |
MTSSerial (PinName TXD, PinName RXD, int txBufferSize=256, int rxBufferSize=256) | |
Creates a new MTSSerial object that can be used to talk to an mbed serial port through internal SW buffers. | |
~MTSSerial () | |
Destructs an MTSSerial object and frees all related resources, including internal buffers. | |
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. | |
virtual void | rxClear () |
This method clears all the data from the internal Rx or read buffer. |
Detailed Description
This class derives from MTSBufferedIO and provides a buffered wrapper to the standard mbed Serial class.
Since it depends only on the mbed Serial class for accessing serial data, this class is inherently portable accross different mbed platforms.
Definition at line 31 of file MTSSerial.h.
Constructor & Destructor Documentation
MTSSerial | ( | PinName | TXD, |
PinName | RXD, | ||
int | txBufferSize = 256 , |
||
int | rxBufferSize = 256 |
||
) |
Creates a new MTSSerial object that can be used to talk to an mbed serial port through internal SW buffers.
- Parameters:
-
TXD the transmit data pin on the desired mbed Serial interface. RXD the receive data pin on the desired mbed Serial interface. txBufferSize the size in bytes of the internal SW transmit buffer. The default is 64 bytes. rxBufferSize the size in bytes of the internal SW receive buffer. The default is 64 bytes.
Definition at line 21 of file MTSSerial.cpp.
~MTSSerial | ( | ) |
Destructs an MTSSerial object and frees all related resources, including internal buffers.
Definition at line 29 of file MTSSerial.cpp.
Member Function Documentation
void baud | ( | int | baudrate ) |
This method is used to the set the baud rate of the serial port.
- Parameters:
-
baudrate the 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 |
||
) |
This method sets the transmission format used by the serial port.
- Parameters:
-
bits the number of bits in a word (5-8; default = 8) parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) stop the 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:
-
data the buffer where data read will be added to. length the 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:
-
data the buffer where data read will be added to. length the 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:
-
data char 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:
-
data char 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, inherited] |
This method clears all the data from the internal Rx or read buffer.
Reimplemented in MTSSerialFlowControl.
Definition at line 142 of file MTSBufferedIO.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:
-
data the byte array to be written. length the 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 | ( | char | data ) | [inherited] |
This method writes a signle byte as a char to the Tx or write buffer.
- Parameters:
-
data the 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 write | ( | char | data, |
unsigned int | timeoutMillis | ||
) | [inherited] |
This method attempts to write a single byte to the tx buffer within the timeout period.
- Parameters:
-
data the 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 | ( | 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:
-
data the byte array to be written. length the 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 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.
Generated on Tue Jul 12 2022 21:46:23 by 1.7.2