Fixed bug where switching to RAW mode would fail due to the "ok" response being received in the same message as the first data frame

Sometimes when opening socketcand 1 or more busses won't start right and there's a ton of debug data saying "received datagramm: ...."
It seems to happen because the switch to RAW mode is in progress and we receive the OK with a frame in the same datagramm and we don't parse the OK out of the string
but rather expect the whole string to just be OK.  Offending code is in socketcand.cpp SocketCANd::procRXData line 386

Fixed by looking to see if the < ok > message was at index 0 of the incoming message...could also look for it elsewhere (as in index != -1), but not sure if necessary
This commit is contained in:
Andy Huska
2022-09-17 12:48:48 -05:00
parent 7b966fe4a6
commit 47d07b8bf2
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -396,6 +396,12 @@ void SocketCANd::procRXData(QString data, int busNum)
{
rx_state[busNum] = RAWMODE;
}
else if(data.indexOf("< ok >", 0, Qt::CaseSensitivity::CaseInsensitive) == 0)
{
qDebug() << "Ok found at start of compound message, switching to RAW and decoding immediately";
rx_state[busNum] = RAWMODE;
decodeFrames(data, busNum);
}
break;
case RAWMODE:
decodeFrames(data, busNum);