Hello to everybody,
i was thinking to replace Yun bridge with my own code…
First of all, here is my scenario
| myBoard | – UART 57600 – pin 10,11 32u4 (SoftwareSerial) – | 32u4 | – Serial1 57600 – | Linux |
Actually, i have one custom made board that is streaming lot of data over a 57600 serial connected to the 32u4 configured with a software serial.
My sketch is simply bridging software serial with Serial1 byte per byte
#include <SoftwareSerial.h>
#include <avr/wdt.h>
#define rxPin 10
#define txPin 11
#define led 13
SoftwareSerial mySerial(rxPin, txPin); // RX, TX
void setup() {
// settaggio dei pin IN/OUT per la seriale software
pinMode(rxPin, INPUT_PULLUP);
pinMode(txPin, OUTPUT);
// settaggio pin LED
pinMode(led, OUTPUT);
mySerial.begin(57600); //inizializzazione della seriale Software
Serial1.begin(57600);
wdt_enable(WDTO_8S);
}
void loop() {
if (mySerial.available()) {
digitalWrite(led, HIGH);
Serial1.write(mySerial.read());
//Serial1.flush();
digitalWrite(led, LOW);
}
if (Serial1.available()) {
mySerial.write(Serial1.read());
}
// resetto il watchdog
wdt_reset();
}
On Linux, i have disable console in /etc/inittab and run this:
stty -F /dev/ttyATH0 57600
and i read serial data coming with
screen /dev/ttyATH0 57600
Now strange things happen:
If i leave Serial1.flush uncommented, sketch freeze and watchdog reset it but as soon as sketch is working (for few seconds) data are coming in correctly.
If i comment flush command, i’m getting incorrect character:
000/09999/000/000/000/000/000/000/16/000|00000/08999/°16/00/00¯000/001/00000/0°°|00000/10999/000/0/000¯°°0/00000/1¶2/092000°00|00000/09999/00/000/000/00/00°/°00/0/000ü00000/08999/16/°0/00°/000/0/000/°00/00|00000/1099/000/000/0°1/000±6/092000/000|0000/0999900/0°°
(should be number, slashes or pipes)
I thought it was a speed problem but if i use Serial and not Serial1 i can see on the serial monitor all the correct data
I also know that original bridge function is running at 250000…
Do you have any idea ?
Thanks
Best Regards
Ettore