mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-28 04:38:55 +08:00
AP_Scripting: CAN: get_device and get_device2 return nil if no driver is configure with the correct protocol
This commit is contained in:
1 parent
632d0a93c1
commit
95a5169439
2 files changed
+16
-4
No files matched your search
@@ -682,6 +682,12 @@ int lua_get_CAN_device(lua_State *L) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!scripting->_CAN_dev->initialized()) {
|
||||
// Driver not initialized, probably because there is no can driver set to scripting
|
||||
// Return nil
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_ScriptingCANBuffer(L);
|
||||
*((ScriptingCANBuffer**)luaL_checkudata(L, -1, "ScriptingCANBuffer")) = scripting->_CAN_dev->add_buffer(buffer_len);
|
||||
|
||||
@@ -707,6 +713,12 @@ int lua_get_CAN_device2(lua_State *L) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!scripting->_CAN_dev2->initialized()) {
|
||||
// Driver not initialized, probably because there is no can driver set to scripting 2
|
||||
// Return nil
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_ScriptingCANBuffer(L);
|
||||
*((ScriptingCANBuffer**)luaL_checkudata(L, -1, "ScriptingCANBuffer")) = scripting->_CAN_dev2->add_buffer(buffer_len);
|
||||
|
||||
|
||||
Reference in new issue
Block a user