We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ba6c116 + 238793f commit 5b5f0c7Copy full SHA for 5b5f0c7
Firmware/LoRaSerial/Commands.ino
@@ -1191,6 +1191,8 @@ const COMMAND_ENTRY commands[] =
1191
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "FlowControl", &tempSettings.flowControl},
1192
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "InvertCts", &tempSettings.invertCts},
1193
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "InvertRts", &tempSettings.invertRts},
1194
+ {'S', 0, 0, 0, SERIAL_RX_BUFFER_SIZE, 0, TYPE_U16, valInt, "RTSOffBytes", &tempSettings.rtsOffBytes},
1195
+ {'S', 0, 0, 0, SERIAL_RX_BUFFER_SIZE, 0, TYPE_U16, valInt, "RTSOnBytes", &tempSettings.rtsOnBytes},
1196
{'S', 0, 0, 10, 2000, 0, TYPE_U16, valInt, "SerialDelay", &tempSettings.serialTimeoutBeforeSendingFrame_ms},
1197
{'S', 0, 0, 0, 0, 0, TYPE_SPEED_SERIAL, valSpeedSerial, "SerialSpeed", &tempSettings.serialSpeed},
1198
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "UsbSerialWait", &tempSettings.usbSerialWait},
Firmware/LoRaSerial/LoRaSerial.ino
@@ -82,6 +82,9 @@ const int FIRMWARE_VERSION_MINOR = 0;
82
#define ENABLE_DEVELOPER false
83
#endif //ENABLE_DEVELOPER
84
85
+#define SERIAL_RX_BUFFER_SIZE 1024
86
+#define RTS_ON_BYTES (SERIAL_RX_BUFFER_SIZE / 4)
87
+
88
#include "settings.h"
89
90
//Hardware connections
@@ -195,7 +198,7 @@ const uint8_t responseDelayDivisor = 4; //Add on to max response time after pack
195
198
//Buffer to receive serial data from the USB or serial ports
196
199
uint16_t rxHead = 0;
197
200
uint16_t rxTail = 0;
-uint8_t serialReceiveBuffer[1024];
201
+uint8_t serialReceiveBuffer[SERIAL_RX_BUFFER_SIZE];
202
203
//Buffer to store bytes for transmission via the long range radio
204
uint16_t radioTxHead = 0;
Firmware/LoRaSerial/Serial.ino
@@ -293,35 +293,37 @@ uint8_t readyOutgoingCommandPacket(uint16_t offset)
293
//Scan for escape characters
294
void updateSerial()
295
{
296
+ int bufferSpace;
297
uint16_t previousHead;
298
int x;
299
300
//Assert RTS when there is enough space in the receive buffer
301
if ((!rtsAsserted) && (availableRXBytes() < (sizeof(serialReceiveBuffer) / 2))
- && (availableTXBytes() < (sizeof(serialTransmitBuffer) / 4)))
302
+ && (availableTXBytes() <= RTS_ON_BYTES))
303
updateRTS(true);
304
305
//Attempt to empty the serialTransmitBuffer
306
outputSerialData(false);
307
308
//Look for local incoming serial
309
previousHead = rxHead;
- while (rtsAsserted && arch.serialAvailable() && (transactionComplete == false))
310
+ bufferSpace = sizeof(serialReceiveBuffer) - 1 - availableRXBytes();
311
+ while (bufferSpace-- && arch.serialAvailable() && (transactionComplete == false))
312
313
blinkSerialRxLed(true); //Turn on LED during serial reception
314
315
//Take a break if there are ISRs to attend to
316
petWDT();
317
if (timeToHop == true) hopChannel();
318
- //Deassert RTS when the buffer gets full
- if (rtsAsserted && (sizeof(serialReceiveBuffer) - availableRXBytes()) < 32)
319
- updateRTS(false);
320
-
321
byte incoming = systemRead();
322
323
serialReceiveBuffer[rxHead++] = incoming; //Push char to holding buffer
324
rxHead %= sizeof(serialReceiveBuffer);
+ //Deassert RTS when the buffer gets full
325
+ if (rtsAsserted && (sizeof(serialReceiveBuffer) - availableRXBytes()) <= settings.rtsOffBytes)
326
+ updateRTS(false);
327
} //End Serial.available()
328
blinkSerialRxLed(false); //Turn off LED
329
Firmware/LoRaSerial/settings.h
@@ -445,6 +445,10 @@ typedef struct struct_settings {
445
uint16_t serialTimeoutBeforeSendingFrame_ms = 50; //Send partial buffer if time expires
446
bool echo = false; //Print locally inputted serial
447
bool flowControl = false; //Enable the use of CTS/RTS flow control signals
448
449
+ uint16_t rtsOffBytes = 32; //Number of free bytes in serialReceiveBuffer when RTS is deasserted
450
+ uint16_t rtsOnBytes = RTS_ON_BYTES; //Number of free bytes in serialReceiveBuffer when RTS is asserted
451
452
#if (ENABLE_DEVELOPER == true)
453
#define WAIT_SERIAL_DEFAULT true
454
#else //ENABLE_DEVELOPER
Firmware/Tools/Command_Validation_Script.txt
@@ -358,6 +358,16 @@ at-InvertCts=2
358
at-InvertCts=1
359
at-InvertCts
360
361
+at-RTSOffBytes=0
362
+at-RTSOffBytes=1025
363
+at-RTSOffBytes=1024
364
+at-RTSOffBytes=32
365
366
+at-RTSOnBytes=0
367
+at-RTSOnBytes=1025
368
+at-RTSOnBytes=1024
369
+at-RTSOnBytes=256
370
371
at-InvertRts=0
372
at-InvertRts=2
373
at-InvertRts=1
0 commit comments