Hi everyone, I believe it's my first post here on the forum but i ran through a serious problem when i was exploring SoftwareSerial library to see its performance in my application and I uploaded the following simple sketch:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);
void setup() {
mySerial.begin(9600);
}
void loop() {
if(mySerial.available())
{
byte data = mySerial.read();
mySerial.write(data);
}
}
It's a simple loopback sketch but the results were surprising...! The library couldn't reply back with the data I sent, even when i tested with data as low as 2 bytes per transaction.
I have tried with all standard baud rates mentioned on Arduino website and even went with rates as low as 300 bps.
Here are some sample data that I sent and received in hex:
Baud Rate = 9600
[TX] - 92 29
[RX] - 92 FF
Baud Rate = 9600
[TX] - FF 29 A5 09 02 FD 02 FD 01 00
[RX] - FF 95 13 02 01 FF
Baud Rate = 4800
[TX] - FF 29 A5 09 02 FD 02 FD 01 00
[RX] - FF 95 13 02 01 FF
Baud Rate = 300
[TX] - FF 29 A5 09 02 FD 02 FD 01 00
[RX] - FF 95 12 02 01 FF
As you may see, there is a pattern. The data is the same but the baud rate is different and still the data sequence is very similar.
My tests were performed using the last version of Arduino 1.6.8 using a USB to serial cable connected to the software serial pins. I repeated the tests on different Windows/OSX machines, different Arduino boards (Uno and Mega) and different USB-Serial cables and all of them had the same results.
I've tried AltSoftSerial library and all my tests where working with baud rates up to 57600 and data up to 200 bytes per transaction.
I think the implementation is broken somehow, I know its an issue related to interruption "as the Tx pin is interrupted by the receiver when sending" but still i can't figure out how to solve this problem on my side.
It is not mentioned anywhere that the communication is half-duplex, As i have tested the library by letting one Arduino sending data using SoftwareSerial and another Arduino receives data also by SoftwareSerial and all the packets were received successfully.
Your documentation mentions that it is possible to have multiple software serial posts with baud rates up to 115200, could you explain how that is possible but running my simple loopback sketch isn't?
Am i missing something ? Please advise.
Thanks,