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
io/MTSSerial.h@46:b30547bf07d5, 2013-12-19 (annotated)
- Committer:
- jengbrecht
- Date:
- Thu Dec 19 21:48:32 2013 +0000
- Revision:
- 46:b30547bf07d5
- Parent:
- 45:40745c2036cf
- Parent:
- 40:14342c4de476
- Child:
- 51:d22d3d87391f
Merged, removed Axeda Wrapper
Who changed what in which revision?
User | Revision | Line number | New 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 | 45:40745c2036cf | 10 | * standard mbed Serial class. Since it depends only on the mbed Serial class for |
jengbrecht | 45:40745c2036cf | 11 | * accessing serial data, this class is inherently portable accross different mbed |
jengbrecht | 45:40745c2036cf | 12 | * platforms. |
jengbrecht | 36:bb6b293c7495 | 13 | */ |
jengbrecht | 0:563b70517320 | 14 | class MTSSerial : public MTSBufferedIO |
jengbrecht | 0:563b70517320 | 15 | { |
jengbrecht | 0:563b70517320 | 16 | public: |
jengbrecht | 45:40745c2036cf | 17 | /** Creates a new MTSSerial object that can be used to talk to an mbed serial port |
jengbrecht | 36:bb6b293c7495 | 18 | * through internal SW buffers. |
jengbrecht | 36:bb6b293c7495 | 19 | * |
jengbrecht | 45:40745c2036cf | 20 | * @param TXD the transmit data pin on the desired mbed Serial interface. |
jengbrecht | 45:40745c2036cf | 21 | * @param RXD the receive data pin on the desired mbed Serial interface. |
jengbrecht | 36:bb6b293c7495 | 22 | * @param txBufferSize the size in bytes of the internal SW transmit buffer. The |
jengbrecht | 36:bb6b293c7495 | 23 | * default is 64 bytes. |
jengbrecht | 36:bb6b293c7495 | 24 | * @param rxBufferSize the size in bytes of the internal SW receive buffer. The |
jengbrecht | 36:bb6b293c7495 | 25 | * default is 64 bytes. |
jengbrecht | 45:40745c2036cf | 26 | * @param name an optional name for the serial port. The default is "". |
jengbrecht | 36:bb6b293c7495 | 27 | */ |
mfiore | 10:2bd727a4b329 | 28 | MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 64, int rxBufferSize = 64, char* name = ""); |
jengbrecht | 36:bb6b293c7495 | 29 | |
jengbrecht | 36:bb6b293c7495 | 30 | /** Destructs an MTSSerial object and frees all related resources, including |
jengbrecht | 36:bb6b293c7495 | 31 | * internal buffers. |
jengbrecht | 36:bb6b293c7495 | 32 | */ |
jengbrecht | 0:563b70517320 | 33 | ~MTSSerial(); |
jengbrecht | 45:40745c2036cf | 34 | |
jengbrecht | 36:bb6b293c7495 | 35 | /** This method is used to the set the baud rate of the serial port. |
jengbrecht | 45:40745c2036cf | 36 | * |
jengbrecht | 45:40745c2036cf | 37 | * @param baudrate the baudrate in bps as an int. The default is 9600 bps. |
jengbrecht | 36:bb6b293c7495 | 38 | */ |
jengbrecht | 0:563b70517320 | 39 | void baud(int baudrate); |
jengbrecht | 0:563b70517320 | 40 | |
jengbrecht | 45:40745c2036cf | 41 | /** This method sets the transmission format used by the serial port. |
jengbrecht | 45:40745c2036cf | 42 | * |
jengbrecht | 45:40745c2036cf | 43 | * @param bits the number of bits in a word (5-8; default = 8) |
jengbrecht | 45:40745c2036cf | 44 | * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, |
jengbrecht | 45:40745c2036cf | 45 | * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) |
jengbrecht | 45:40745c2036cf | 46 | * @param stop the number of stop bits (1 or 2; default = 1) |
jengbrecht | 36:bb6b293c7495 | 47 | */ |
jengbrecht | 45:40745c2036cf | 48 | void format(int bits=8, SerialBase::Parity parity=SerialBase::None, int stop_bits=1); |
jengbrecht | 0:563b70517320 | 49 | |
jengbrecht | 0:563b70517320 | 50 | private: |
jengbrecht | 0:563b70517320 | 51 | Serial* serial; // Internal mbed Serial object |
jengbrecht | 0:563b70517320 | 52 | int writeSize; // Amount of data to write based on buffer size |
mfiore | 10:2bd727a4b329 | 53 | char* if_name; // Name of the interface |
jengbrecht | 45:40745c2036cf | 54 | |
jengbrecht | 45:40745c2036cf | 55 | virtual void handleWrite(); // Method for handling data to be written |
jengbrecht | 45:40745c2036cf | 56 | virtual void handleRead(); // Method for handling data to be read |
jengbrecht | 0:563b70517320 | 57 | }; |
jengbrecht | 0:563b70517320 | 58 | |
mfiore | 39:6e94520a3217 | 59 | } |
mfiore | 39:6e94520a3217 | 60 | |
jengbrecht | 0:563b70517320 | 61 | #endif /* MTSSERIAL_H */ |