Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
Diff: io/MTSSerialFlowControl.cpp
- Revision:
- 86:186bbf974c7c
- Parent:
- 83:9813f9b8ee68
- Parent:
- 85:b17ad6781c5b
- Child:
- 96:27bdf4aa3a31
--- a/io/MTSSerialFlowControl.cpp Fri Dec 27 15:55:35 2013 +0000
+++ b/io/MTSSerialFlowControl.cpp Fri Dec 27 16:40:23 2013 +0000
@@ -1,46 +1,42 @@
-#ifndef MTSSERIALFLOWCONTROL_CPP
-#define MTSSERIALFLOWCONTROL_CPP
-
#include "MTSSerialFlowControl.h"
using namespace mts;
-MTSSerialFlowControl::MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize, int rxBufSize, char* name) : MTSSerial(TXD, RXD, txBufSize, rxBufSize, name)
+MTSSerialFlowControl::MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize, int rxBufSize)
+: MTSSerial(TXD, RXD, txBufSize, rxBufSize)
+, rts(RTS)
+, cts(CTS)
{
- rts = new DigitalOut(RTS);
- cts = new DigitalIn(CTS);
notifyStartSending();
- //highThreshold = MAX(rxBufSize - 10, rxBufSize * 0.85);
- highThreshold = 10;
+ highThreshold = MAX(rxBufSize - 10, rxBufSize * 0.85);
lowThreshold = rxBufSize * 0.3;
- rxBuffer->attach(this, &MTSSerialFlowControl::notifyStartSending, lowThreshold, Vars::LESS);
+ rxBuffer.attach(this, &MTSSerialFlowControl::notifyStartSending, lowThreshold, Vars::LESS);
}
MTSSerialFlowControl::~MTSSerialFlowControl()
{
- delete rts;
- delete cts;
+
}
void MTSSerialFlowControl::notifyStartSending()
{
- rts->write(0);
- //printf("RTS: START SENDING US BYTES - RX[%d]\r\n", rxBuffer->size());
+ rts.write(0);
+ //printf("RTS: START SENDING US BYTES - RX[%d]\r\n", rxBuffer.size());
}
void MTSSerialFlowControl::notifyStopSending()
{
- rts->write(1);
- //printf("RTS: STOP SENDING US BYTES - RX[%d]\r\n", rxBuffer->size());
+ rts.write(1);
+ //printf("RTS: STOP SENDING US BYTES - RX[%d]\r\n", rxBuffer.size());
}
void MTSSerialFlowControl::handleRead()
{
- while (serial->readable()) {
- rxBuffer->write(serial->getc());
- if (rxBuffer->size() > highThreshold) {
+ while (serial.readable()) {
+ rxBuffer.write(serial.getc());
+ if (rxBuffer.size() > highThreshold) {
notifyStopSending();
}
}
@@ -48,16 +44,14 @@
void MTSSerialFlowControl::handleWrite()
{
- while(txBuffer->size() != 0) {
- if (serial->writeable() && cts->read() == 0) {
+ while(txBuffer.size() != 0) {
+ if (serial.writeable() && cts.read() == 0) {
char byte;
- if(txBuffer->read(byte) == 1) {
- serial->putc(byte);
+ if(txBuffer.read(byte) == 1) {
+ serial.putc(byte);
}
} else {
return;
}
}
}
-
-#endif /* MTSSERIALFLOWCONTROL */
\ No newline at end of file
uIP Socket Modem Shield (Outdated - see below)