Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15733

Bug? - additional zero when Serial0 not begun

$
0
0

Hey all,
I am unsure if this is a bug or if I trigger a latent weirdness.
Background: Arduino Mega to control multiple devices via 3 hardware serial ports (1-3) via an MAX3243.

I set up a simple wrapper class around the serial ports and predefine the command arrays for the device control in my class header file in the init area as const static to save sram. The wrapper class initializes its according port and write various commands to it. Now the weird part.

My commands are stored in a char array:
const static char cmd_info_stat[] = {0x7E,0x30,0x30,0x31,0x35,0x30,0x20,0x31,0x0d};
This is important so that I can terminate with a \r char. The command is then sent via the serial write (I also tried .print(xxx), but same issue):
(*projector).write(cmd_info_stat);

If only serial1 or higher is initialized in the main ino file via a wrapper class, the serial sent output has an added 0 in:
~00150 01
If, however, in the main function I begin serial0 (you know, "Serial") BEFORE initializing the wrapper class, the correct output is sent via serial1:
~00150 1
I can not wrap (pun intended) my head around it. On what behaviour do I hit here?

9 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 15733

Latest Images

Trending Articles



Latest Images