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.h
00001 /* Universal Socket Modem Interface Library 00002 * Copyright (c) 2013 Multi-Tech Systems 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef MTSSERIAL_H 00018 #define MTSSERIAL_H 00019 00020 #include "mbed.h" 00021 #include "MTSBufferedIO.h" 00022 00023 namespace mts 00024 { 00025 00026 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the 00027 * standard mbed Serial class. Since it depends only on the mbed Serial class for 00028 * accessing serial data, this class is inherently portable accross different mbed 00029 * platforms. 00030 */ 00031 class MTSSerial : public MTSBufferedIO 00032 { 00033 public: 00034 /** Creates a new MTSSerial object that can be used to talk to an mbed serial port 00035 * through internal SW buffers. 00036 * 00037 * @param TXD the transmit data pin on the desired mbed Serial interface. 00038 * @param RXD the receive data pin on the desired mbed Serial interface. 00039 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The 00040 * default is 64 bytes. 00041 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The 00042 * default is 64 bytes. 00043 */ 00044 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 256, int rxBufferSize = 256); 00045 00046 /** Destructs an MTSSerial object and frees all related resources, including 00047 * internal buffers. 00048 */ 00049 ~MTSSerial(); 00050 00051 /** This method is used to the set the baud rate of the serial port. 00052 * 00053 * @param baudrate the baudrate in bps as an int. The default is 9600 bps. 00054 */ 00055 void baud(int baudrate); 00056 00057 /** This method sets the transmission format used by the serial port. 00058 * 00059 * @param bits the number of bits in a word (5-8; default = 8) 00060 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, 00061 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None) 00062 * @param stop the number of stop bits (1 or 2; default = 1) 00063 */ 00064 void format(int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1); 00065 00066 protected: 00067 Serial serial; // Internal mbed Serial object 00068 00069 private: 00070 virtual void handleWrite(); // Method for handling data to be written 00071 virtual void handleRead(); // Method for handling data to be read 00072 }; 00073 00074 } 00075 00076 #endif /* MTSSERIAL_H */
Generated on Tue Jul 12 2022 21:46:23 by 1.7.2