Serial library for MTS Socket Modem Arduino Shield devices from Multi-Tech Systems
Dependents: mDot_AT_firmware mtsas mtsas MTDOT-EVB-LinkCheck-AL ... more
Revision 13:643ad09fc0e0, committed 2020-09-11
- Comitter:
- Jason Reiss
- Date:
- Fri Sep 11 11:26:01 2020 -0500
- Parent:
- 12:e12b79a4ab4f
- Commit message:
- Sync to 42356b91d1700c77144ebf97df131503991c7317
Changed in this revision
--- a/MTSBufferedIO.cpp Thu Mar 23 16:15:14 2017 -0500 +++ b/MTSBufferedIO.cpp Fri Sep 11 11:26:01 2020 -0500 @@ -16,14 +16,14 @@ } int MTSBufferedIO::writef(const char* format, ...) { - char buff[256]; + char buff[512]; va_list ap; va_start(ap, format); - int len = vsnprintf(buff, 256, format, ap); + int len = vsnprintf(buff, 512, format, ap); while (!writeable()) ; - write(buff, len); + write(buff, std::min<int>(len,512)); va_end(ap); return len; }
--- a/MTSBufferedIO.h Thu Mar 23 16:15:14 2017 -0500 +++ b/MTSBufferedIO.h Fri Sep 11 11:26:01 2020 -0500 @@ -43,7 +43,7 @@ * the buffer is full. */ int write(const char* data, int length, unsigned int timeoutMillis); - + /** This method enables bulk writes to the Tx or write buffer. This method * blocks until all the bytes are written. * @@ -52,7 +52,7 @@ * @returns the number of bytes written to the buffer, which should be * equal to the length parameter since this method blocks. */ - int write(const char* data, int length); + int write(const char* data, int length); /** This method enables bulk writes to the Tx or write buffer. This method * blocks until all the bytes are written. @@ -72,7 +72,7 @@ * expired. */ int write(char data, unsigned int timeoutMillis); - + /** This method writes a single byte as a char to the Tx or write buffer. * This method blocks until the byte is written. * @@ -97,7 +97,7 @@ * @returns the total number of bytes that were read. */ int read(char* data, int length, unsigned int timeoutMillis); - + /** This method enables bulk reads from the Rx or read buffer. This method * blocks until the amount of data requested is received. * @@ -117,7 +117,7 @@ * @returns 1 if byte is read or 0 if no byte is available. */ int read(char& data, unsigned int timeoutMillis); - + /** This method reads a single byte from the Rx or read buffer. * This method blocks until the single byte is read. * @@ -167,13 +167,13 @@ /** This abstract method should be used by the deriving class to transfer * data from the internal write buffer (txBuffer) to the physical interface. - * Note that this function is called everytime new data is written to the + * Note that this function is called every time new data is written to the * txBuffer through one of the write calls. */ virtual void handleWrite() = 0; /** This abstract method should be used by the deriving class to transfer - * data from the physical interface ot the internal read buffer (rxBuffer). + * data from the physical interface to the internal read buffer (rxBuffer). * Note that this function is never called in this class and typically should * be called as part of a receive data interrupt routine. */ @@ -181,7 +181,7 @@ protected: MTSCircularBuffer txBuffer; // Internal write or transmit circular buffer - MTSCircularBuffer rxBuffer; // Internal read or receieve circular buffer + MTSCircularBuffer rxBuffer; // Internal read or receive circular buffer }; }
--- a/MTSSerial.cpp Thu Mar 23 16:15:14 2017 -0500 +++ b/MTSSerial.cpp Fri Sep 11 11:26:01 2020 -0500 @@ -12,7 +12,7 @@ _parity(mbed::SerialBase::None), _stop_bits(1) { - _serial->attach(this, &MTSSerial::handleRead, Serial::RxIrq); + _serial->attach(callback(this, &MTSSerial::handleRead), Serial::RxIrq); } MTSSerial::~MTSSerial() @@ -36,7 +36,7 @@ } void MTSSerial::handleRead() -{ +{ rxBuffer.write(_serial->getc()); } @@ -48,7 +48,7 @@ if(txBuffer.read(byte) == 1) { _serial->attach(NULL, Serial::RxIrq); _serial->putc(byte); - _serial->attach(this, &MTSSerial::handleRead, Serial::RxIrq); + _serial->attach(callback(this, &MTSSerial::handleRead), Serial::RxIrq); } } else { return; @@ -59,7 +59,7 @@ void mts::MTSSerial::reattach(PinName TXD, PinName RXD) { delete _serial; _serial = new RawSerial(TXD, RXD); - _serial->attach(this, &MTSSerial::handleRead, Serial::RxIrq); + _serial->attach(callback(this, &MTSSerial::handleRead), Serial::RxIrq); _serial->baud(_baudrate); _serial->format(_bits, _parity, _stop_bits); rxBuffer.clear();
--- a/MTSSerialFlowControl.cpp Thu Mar 23 16:15:14 2017 -0500 +++ b/MTSSerialFlowControl.cpp Fri Sep 11 11:26:01 2020 -0500 @@ -69,7 +69,7 @@ if(txBuffer.read(byte) == 1) { _serial->attach(NULL, Serial::RxIrq); _serial->putc(byte); - _serial->attach(this, &MTSSerialFlowControl::handleRead, Serial::RxIrq); + _serial->attach(callback(this, &MTSSerialFlowControl::handleRead), Serial::RxIrq); } } else { return;