Closed deHarro closed 5 years ago
You are right, I will change it next time.
It's already implemented in the current version. I check for CR or LF:
private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{ while ((serialPort.IsOpen) && (serialPort.BytesToRead > 0))
{
byte[] rxBuff = new byte[serialPort.BytesToRead];
serialPort.Read(rxBuff, 0, serialPort.BytesToRead);
byte rxTmpChar = 0;
try
{ foreach (byte rxTmpChart in rxBuff)
{
rxTmpChar = rxTmpChart;
if ((rxTmpChar > 0x7F) || (isRealTimeCmd.Contains(rxTmpChar))) // is real time cmd ?
{ rxChar = rxTmpChar;
this.Invoke(new EventHandler(handleRxData));
}
else
{ rxTmpString += (char)rxTmpChar;
if ((rxTmpChar == '\r') || (rxTmpChar == '\n')) // end of regular command
{ if (lastChar >= ' ')
{
rxChar = 0;
rxString = rxTmpString.Trim();
this.Invoke(new EventHandler(handleRxData));
}
rxTmpString = "";
}
}
lastChar = rxTmpChar;
}
}
catch (Exception errort)
{ serialPort.Close();
logError("Error reading line from serial port", errort);
}
}
}
Hi Sven,
This is not a big issue since your current implementation works, but I wanted to point it out.
You recently pointed me to the instructions for GRBL communication and we got through all of theses in the past. You posted the relevant code part for communication to my joystick as:
I just again read our discussion on the communication to GRBL and I stumbeled over the following instructions on the GRBL V1.1 site:
So your implementation seems to be over defined, you search for "CR LF", GRBL only wants "CR".
Harald