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

Committer:
jengbrecht
Date:
Thu Dec 19 21:38:01 2013 +0000
Revision:
45:40745c2036cf
Parent:
36:bb6b293c7495
Child:
46:b30547bf07d5
Added a ton of documentation, made the notify start and stop methods private in MTSSerialFlowControl, added format method to the serial classes, fixed an issue in the bulk write method of MTSCircularBuffer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jengbrecht 0:563b70517320 1 #ifndef MTSSERIAL_H
jengbrecht 0:563b70517320 2 #define MTSSERIAL_H
jengbrecht 0:563b70517320 3
jengbrecht 0:563b70517320 4 #include "mbed.h"
jengbrecht 0:563b70517320 5 #include "MTSBufferedIO.h"
jengbrecht 0:563b70517320 6
jengbrecht 36:bb6b293c7495 7 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the
jengbrecht 45:40745c2036cf 8 * standard mbed Serial class. Since it depends only on the mbed Serial class for
jengbrecht 45:40745c2036cf 9 * accessing serial data, this class is inherently portable accross different mbed
jengbrecht 45:40745c2036cf 10 * platforms.
jengbrecht 36:bb6b293c7495 11 */
jengbrecht 0:563b70517320 12 class MTSSerial : public MTSBufferedIO
jengbrecht 0:563b70517320 13 {
jengbrecht 0:563b70517320 14 public:
jengbrecht 45:40745c2036cf 15 /** Creates a new MTSSerial object that can be used to talk to an mbed serial port
jengbrecht 36:bb6b293c7495 16 * through internal SW buffers.
jengbrecht 36:bb6b293c7495 17 *
jengbrecht 45:40745c2036cf 18 * @param TXD the transmit data pin on the desired mbed Serial interface.
jengbrecht 45:40745c2036cf 19 * @param RXD the receive data pin on the desired mbed Serial interface.
jengbrecht 36:bb6b293c7495 20 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
jengbrecht 36:bb6b293c7495 21 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 22 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
jengbrecht 36:bb6b293c7495 23 * default is 64 bytes.
jengbrecht 45:40745c2036cf 24 * @param name an optional name for the serial port. The default is "".
jengbrecht 36:bb6b293c7495 25 */
mfiore 10:2bd727a4b329 26 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 64, int rxBufferSize = 64, char* name = "");
jengbrecht 36:bb6b293c7495 27
jengbrecht 36:bb6b293c7495 28 /** Destructs an MTSSerial object and frees all related resources, including
jengbrecht 36:bb6b293c7495 29 * internal buffers.
jengbrecht 36:bb6b293c7495 30 */
jengbrecht 0:563b70517320 31 ~MTSSerial();
jengbrecht 45:40745c2036cf 32
jengbrecht 36:bb6b293c7495 33 /** This method is used to the set the baud rate of the serial port.
jengbrecht 45:40745c2036cf 34 *
jengbrecht 45:40745c2036cf 35 * @param baudrate the baudrate in bps as an int. The default is 9600 bps.
jengbrecht 36:bb6b293c7495 36 */
jengbrecht 0:563b70517320 37 void baud(int baudrate);
jengbrecht 0:563b70517320 38
jengbrecht 45:40745c2036cf 39 /** This method sets the transmission format used by the serial port.
jengbrecht 45:40745c2036cf 40 *
jengbrecht 45:40745c2036cf 41 * @param bits the number of bits in a word (5-8; default = 8)
jengbrecht 45:40745c2036cf 42 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even,
jengbrecht 45:40745c2036cf 43 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
jengbrecht 45:40745c2036cf 44 * @param stop the number of stop bits (1 or 2; default = 1)
jengbrecht 36:bb6b293c7495 45 */
jengbrecht 45:40745c2036cf 46 void format(int bits=8, SerialBase::Parity parity=SerialBase::None, int stop_bits=1);
jengbrecht 0:563b70517320 47
jengbrecht 0:563b70517320 48 private:
jengbrecht 0:563b70517320 49 Serial* serial; // Internal mbed Serial object
jengbrecht 0:563b70517320 50 int writeSize; // Amount of data to write based on buffer size
mfiore 10:2bd727a4b329 51 char* if_name; // Name of the interface
jengbrecht 45:40745c2036cf 52
jengbrecht 45:40745c2036cf 53 virtual void handleWrite(); // Method for handling data to be written
jengbrecht 45:40745c2036cf 54 virtual void handleRead(); // Method for handling data to be read
jengbrecht 0:563b70517320 55 };
jengbrecht 0:563b70517320 56
jengbrecht 0:563b70517320 57 #endif /* MTSSERIAL_H */