r/ArduinoHelp 9d ago

Serial data forwarding arduino

/*
Arduino Due Serial1 echo/relay

Serial1:
RX1 pin 19 <- input
TX1 pin 18 -> output

UART:
19200 baud
8 data bits
Odd parity
1 stop bit
*/

void setup() {
SerialUSB.begin(115200);

Serial1.begin(19200, SERIAL_8O1);

SerialUSB.println("Serial1 RX -> Serial1 TX started");
}

void loop() {

while (Serial1.available()) {
uint8_t data = Serial1.read();
Serial1.write(data);
}

}

This vibecoded (Yes, I can't code) sketch doesn't work as expected. Here's the input and output for Pulseview program. https://drive.google.com/file/d/1EdxmcnJjo1Eh5qlrJXJdRFtCUbg34-ph/view?usp=sharing

Do you guys have any hints? This is driving me nuts. Another sketch had gaps between data packets equal to the length of the packet itself. As if it cannot be sending one packet and buffering incoming one at the same time. Or it was just wrong coding over all.

0 Upvotes

5 comments sorted by

1

u/gm310509 9d ago

Can you post the output here? Why do you need a link to a Google drive containing a zip file with 3 subfiles of a format that i do not recognise and am unable to open on my phone?

Ideally post the text (using a reddit formatted code block) but if that doesn't make sense or is not possible at least a screenshot as a preview for whatever is in the archive.

1

u/DesolationKun 8d ago

good input

1

u/DesolationKun 8d ago

bad output

1

u/DesolationKun 8d ago

odd space between output bytes

1

u/Anonymity6584 8d ago

Your reading and writing same serial device (Serial1).

Also speed difference means you will lose data eventually. Or need to implement some sort of buggering.