Fixed bugs related to scripting and UDS, implemented more scripting
functionality for ISOTP and UDS
This commit is contained in:
@@ -169,12 +169,14 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
|
|||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
udsMsg.data = msg.data.mid(2, -1); //don't copy error byte nor service byte
|
udsMsg.data = msg.data.mid(2, -1); //don't copy error byte nor service byte
|
||||||
|
udsMsg.len -= 2; //and remove those bytes from the length reported too.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
udsMsg.isErrorReply = false;
|
udsMsg.isErrorReply = false;
|
||||||
if (msg.data.length() > 1) udsMsg.subFunc = msg.data.at(1);
|
if (msg.data.length() > 1) udsMsg.subFunc = msg.data.at(1);
|
||||||
udsMsg.data = msg.data.mid(1, -1); //don't copy service byte
|
udsMsg.data = msg.data.mid(1, -1); //don't copy service byte
|
||||||
|
udsMsg.len -= 1; //and remove service byte from length too.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|||||||
+6
-1
@@ -49,6 +49,8 @@ void ScriptContainer::compileScript()
|
|||||||
//Find out which callbacks the script has created.
|
//Find out which callbacks the script has created.
|
||||||
setupFunction = scriptEngine.globalObject().property("setup");
|
setupFunction = scriptEngine.globalObject().property("setup");
|
||||||
canHelper->setRxCallback(scriptEngine.globalObject().property("gotCANFrame"));
|
canHelper->setRxCallback(scriptEngine.globalObject().property("gotCANFrame"));
|
||||||
|
isoHelper->setRxCallback(scriptEngine.globalObject().property("gotISOTPMessage"));
|
||||||
|
udsHelper->setRxCallback(scriptEngine.globalObject().property("gotUDSMessage"));
|
||||||
|
|
||||||
tickFunction = scriptEngine.globalObject().property("tick");
|
tickFunction = scriptEngine.globalObject().property("tick");
|
||||||
|
|
||||||
@@ -245,6 +247,7 @@ void ISOTPScriptHelper::setRxCallback(QJSValue cb)
|
|||||||
|
|
||||||
void ISOTPScriptHelper::newISOMessage(ISOTP_MESSAGE msg)
|
void ISOTPScriptHelper::newISOMessage(ISOTP_MESSAGE msg)
|
||||||
{
|
{
|
||||||
|
qDebug() << "isotpScriptHelper got a ISOTP message";
|
||||||
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
||||||
//qDebug() << "Got frame in script interface";
|
//qDebug() << "Got frame in script interface";
|
||||||
|
|
||||||
@@ -318,6 +321,8 @@ void UDSScriptHelper::setRxCallback(QJSValue cb)
|
|||||||
|
|
||||||
void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
|
void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "udsScriptHelper got a UDS message";
|
||||||
|
qDebug() << "UDS script helper. Meg data len: " << msg.len;
|
||||||
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
|
||||||
//qDebug() << "Got frame in script interface";
|
//qDebug() << "Got frame in script interface";
|
||||||
|
|
||||||
@@ -325,7 +330,7 @@ void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
|
|||||||
args << msg.bus << msg.ID << msg.service << msg.subFunc << msg.len;
|
args << msg.bus << msg.ID << msg.service << msg.subFunc << msg.len;
|
||||||
QJSValue dataBytes = scriptEngine->newArray(msg.len);
|
QJSValue dataBytes = scriptEngine->newArray(msg.len);
|
||||||
|
|
||||||
for (unsigned int j = 0; j < msg.len; j++) dataBytes.setProperty(j, QJSValue(msg.data[j]));
|
for (unsigned int j = 0; j < msg.data.length(); j++) dataBytes.setProperty(j, QJSValue(msg.data[j]));
|
||||||
args.append(dataBytes);
|
args.append(dataBytes);
|
||||||
gotFrameFunction.call(args);
|
gotFrameFunction.call(args);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user