SimHub
SimHub copied to clipboard
Arduino Leonardo not read custom protocol
Arduino Leonardo not read serial from simhub by using custom serial devices.
Simhub version 9.3.4
Arduino sketch
int gear = Serial.readStringUntil(';').toInt(); int hdl = Serial.readStringUntil('\n').toInt();
if((gear) == 'P')
{
setShifterStatus(shifter_status_parking);
Serial.println('OK');
}
if((gear) == 'R')
{
setShifterStatus(shifter_status_reverse);
Serial.println('OK');
}
if((gear) == 'N')
{
setShifterStatus(shifter_status_neutral);
Serial.println('OK');
}
if((gear) == 'D')
{
setShifterStatus(shifter_status_drive);
Serial.println('OK');
}
if(hdl == 1)
{
turnonBacklight();
Serial.println('HDL');
}
else
{
turnoffBacklight();
}
Simhub NCalc format([Gear], 'P') + ';' +isnull([GameRawData.light_LowBeam], 0)
It work only use Serial.read(); Arduino will report serial to simhub.
When change to Serial.readStringUntil(';').toInt(); Nothing send back to simhub.
Sorry for my bad english.