Using the Example SerialGateway like this...
// Enable debug prints to serial monitor
//#define MY_DEBUG
// Enable and select radio type attached
//#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
//#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
//#if F_CPU == 8000000L
//#define MY_BAUD_RATE 38400
//#endif
// Flash leds on rx/tx/err
//#define MY_LEDS_BLINKING_FEATURE
// Set blinking period
//#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
//#define MY_WITH_LEDS_BLINKING_INVERSE
// Enable inclusion mode
//#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
//#define MY_INCLUSION_BUTTON_FEATURE
// Inverses behavior of inclusion button (if using external pullup)
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
// Set inclusion mode duration (in seconds)
//#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
//#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <SPI.h>
#include <MySensors.h>
void setup() {
// Setup locally attached sensors
}
void presentation() {
// Present locally attached sensors
}
void loop() {
// Send locally attached sensor data here
}
void serialEvent()
{ while (Serial.available())
{ String tStr = Serial.readString();
if (tStr.charAt(0) == '*')
{ Serial.print(" testing here = ");
Serial.print(tStr);
Serial.println(">");
} else
{ Serial.print("junk ");
Serial.print(tStr);
Serial.println(">");
}
}
}
When I send stuff *nbvbnvbv via the Arduino Terminal or my own Serial software I get this...
testing here = *nbvbnvbv>
junk bvbnvbv>
testing here = *nbvbnvbv>
testing here = *nbvbnvbv>
testing here = *nbvbnvbv>
junk nbvbnvbv>
testing here = *nbvbnvbv>
junk nbvbnvbv>
testing here = *nbvbnvbv>
testing here = *nbvbnvbv>
junk nbvbnvbv>
junk bvbnvbv>
As you can see characters are getting lost. If I use the Arduino basic sketch and add the serialEvent to it, I never get dropped characters. I assume MySensors is off checking other stuff and misses the incoming Serial stream.
How can I work around this as I need that '*' as the first character to signify a control string.
How can I give the Serial the first bite at the cherry, always?