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:
mfiore
Date:
Thu Dec 19 19:53:43 2013 +0000
Revision:
40:14342c4de476
Parent:
36:bb6b293c7495
Parent:
39:6e94520a3217
Child:
46:b30547bf07d5
merge changes

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
mfiore 39:6e94520a3217 7 namespace mts {
mfiore 40:14342c4de476 8
jengbrecht 36:bb6b293c7495 9 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the
jengbrecht 36:bb6b293c7495 10 * standard Mbed Serial class. Since it depends only on the Mbed Serial class for
jengbrecht 36:bb6b293c7495 11 * accessing serial data, this class is inherently portable accross Mbed platforms.
jengbrecht 36:bb6b293c7495 12 */
jengbrecht 0:563b70517320 13 class MTSSerial : public MTSBufferedIO
jengbrecht 0:563b70517320 14 {
jengbrecht 0:563b70517320 15 public:
jengbrecht 36:bb6b293c7495 16 /** Creates a new MTSSerial object that can be used to talk to an Mbed serial port
jengbrecht 36:bb6b293c7495 17 * through internal SW buffers.
jengbrecht 36:bb6b293c7495 18 *
jengbrecht 36:bb6b293c7495 19 * @param TXD the transmit data pin on the desired Mbed serial interface.
jengbrecht 36:bb6b293c7495 20 * @param RXD the receive data pin on the desired Mbed serial interface.
jengbrecht 36:bb6b293c7495 21 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
jengbrecht 36:bb6b293c7495 22 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 23 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
jengbrecht 36:bb6b293c7495 24 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 25 * @param name an optional name for the serial port. The default is blank.
jengbrecht 36:bb6b293c7495 26 */
mfiore 10:2bd727a4b329 27 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 64, int rxBufferSize = 64, char* name = "");
jengbrecht 36:bb6b293c7495 28
jengbrecht 36:bb6b293c7495 29 /** Destructs an MTSSerial object and frees all related resources, including
jengbrecht 36:bb6b293c7495 30 * internal buffers.
jengbrecht 36:bb6b293c7495 31 */
jengbrecht 0:563b70517320 32 ~MTSSerial();
jengbrecht 36:bb6b293c7495 33
jengbrecht 36:bb6b293c7495 34 /** This method is used to the set the baud rate of the serial port.
jengbrecht 36:bb6b293c7495 35 *
jengbrecht 36:bb6b293c7495 36 * @param baudrate the baudrate in bps as an int. The internal interface
jengbrecht 36:bb6b293c7495 37 * default is 9600 bps.
jengbrecht 36:bb6b293c7495 38 */
jengbrecht 0:563b70517320 39 void baud(int baudrate);
jengbrecht 36:bb6b293c7495 40
jengbrecht 0:563b70517320 41 // void format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1);
jengbrecht 0:563b70517320 42
jengbrecht 36:bb6b293c7495 43 /** Overridden method used internally to handle reading from the serial interface.
jengbrecht 36:bb6b293c7495 44 * Do not call directly, use data access methods available in MTSBufferedIO.
jengbrecht 36:bb6b293c7495 45 */
jengbrecht 36:bb6b293c7495 46 virtual void handleRead();
jengbrecht 36:bb6b293c7495 47
jengbrecht 36:bb6b293c7495 48 /** Overridden method used internally to handle writing to the serial interface.
jengbrecht 36:bb6b293c7495 49 * Do not call directly, use data access methods available in MTSBufferedIO.
jengbrecht 36:bb6b293c7495 50 */
jengbrecht 36:bb6b293c7495 51 virtual void handleWrite();
jengbrecht 0:563b70517320 52
jengbrecht 0:563b70517320 53 private:
jengbrecht 0:563b70517320 54 Serial* serial; // Internal mbed Serial object
jengbrecht 0:563b70517320 55 int writeSize; // Amount of data to write based on buffer size
mfiore 10:2bd727a4b329 56 char* if_name; // Name of the interface
jengbrecht 0:563b70517320 57 };
jengbrecht 0:563b70517320 58
mfiore 39:6e94520a3217 59 }
mfiore 39:6e94520a3217 60
jengbrecht 0:563b70517320 61 #endif /* MTSSERIAL_H */