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.
1 parent e0c533e commit 238793fCopy full SHA for 238793f
Firmware/LoRaSerial/Commands.ino
@@ -1188,6 +1188,8 @@ const COMMAND_ENTRY commands[] =
1188
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "FlowControl", &tempSettings.flowControl},
1189
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "InvertCts", &tempSettings.invertCts},
1190
{'S', 0, 0, 0, 1, 0, TYPE_BOOL, valInt, "InvertRts", &tempSettings.invertRts},
1191
+ {'S', 0, 0, 0, SERIAL_RX_BUFFER_SIZE, 0, TYPE_U16, valInt, "RTSOffBytes", &tempSettings.rtsOffBytes},
1192
+ {'S', 0, 0, 0, SERIAL_RX_BUFFER_SIZE, 0, TYPE_U16, valInt, "RTSOnBytes", &tempSettings.rtsOnBytes},
1193
{'S', 0, 0, 10, 2000, 0, TYPE_U16, valInt, "SerialDelay", &tempSettings.serialTimeoutBeforeSendingFrame_ms},
1194
{'S', 0, 0, 0, 0, 0, TYPE_SPEED_SERIAL, valSpeedSerial, "SerialSpeed", &tempSettings.serialSpeed},
1195
{'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
@@ -291,35 +291,37 @@ uint8_t readyOutgoingCommandPacket(uint16_t offset)
291
//Scan for escape characters
292
void updateSerial()
293
{
294
+ int bufferSpace;
295
uint16_t previousHead;
296
int x;
297
298
//Assert RTS when there is enough space in the receive buffer
299
if ((!rtsAsserted) && (availableRXBytes() < (sizeof(serialReceiveBuffer) / 2))
- && (availableTXBytes() < (sizeof(serialTransmitBuffer) / 4)))
300
+ && (availableTXBytes() <= RTS_ON_BYTES))
301
updateRTS(true);
302
303
//Attempt to empty the serialTransmitBuffer
304
outputSerialData(false);
305
306
//Look for local incoming serial
307
previousHead = rxHead;
- while (rtsAsserted && arch.serialAvailable() && (transactionComplete == false))
308
+ bufferSpace = sizeof(serialReceiveBuffer) - 1 - availableRXBytes();
309
+ while (bufferSpace-- && arch.serialAvailable() && (transactionComplete == false))
310
311
blinkSerialRxLed(true); //Turn on LED during serial reception
312
313
//Take a break if there are ISRs to attend to
314
petWDT();
315
if (timeToHop == true) hopChannel();
316
- //Deassert RTS when the buffer gets full
- if (rtsAsserted && (sizeof(serialReceiveBuffer) - availableRXBytes()) < 32)
317
- updateRTS(false);
318
-
319
byte incoming = systemRead();
320
321
serialReceiveBuffer[rxHead++] = incoming; //Push char to holding buffer
322
rxHead %= sizeof(serialReceiveBuffer);
+ //Deassert RTS when the buffer gets full
323
+ if (rtsAsserted && (sizeof(serialReceiveBuffer) - availableRXBytes()) <= settings.rtsOffBytes)
324
+ updateRTS(false);
325
} //End Serial.available()
326
blinkSerialRxLed(false); //Turn off LED
327
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