I have two identical Uno boards communicating over tx/rx using software serial (pins 8/9).
board #1 and #2 share 5v and GND..
software serial out on board 1 -> RX board2,
serial in -> TX on board 2
On board #2 I have grbl v1.1 installed (baud 115200).
On board #1 I have a custom program that talks between PC over serial (using cmdmessenger). I have logic in the loop to evaluate:
void loop() {
while (mySerial.available() > 0)
processIncomingByte(mySerial.read());
}
void processIncomingByte (const byte inByte)
{
static char input_line [MAX_INPUT];
static unsigned int input_pos = 0;
switch (inByte)
{
case '\n': // end of text
input_line [input_pos] = 0; // terminating null byte
cmdMessenger.sendCmd(kReceiveGrblCmd, input_line);
input_pos = 0;
break;
case '\r': // discard carriage return
break;
default:
if (input_pos < (MAX_INPUT - 1))
input_line [input_pos++] = inByte;
break;
}
}
The problem is that the messages are partially garbled.. here is example data from the PC when sending "$$\n" to grbl:
$0=10$1=25
$2=0CÏ
$4=0C!RSj
$6=0C!Rêj
$12=.002
$11Orj
$13=0C!&ê0j
$200r
Or
!
Grbl 1.1f «Ò2½ÉB±Áu5
What I don't understand is that why is part of the data correct at first and then is garbled on the ends of data?
This is what the data should look like:
$0=10
$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=1
$23=0
$24=25.000
$25=500.000
$26=250
$27=1.000
$30=1000.
$31=0.
$32=0
$100=250.000
$101=250.000
$102=250.000
$110=500.000
$111=500.000
$112=500.000
$120=10.000
$121=10.000
$122=10.000
$130=200.000
$131=200.000
$132=200.000