mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04: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:
parent
632d0a93c1
commit
95a5169439
@ -344,14 +344,14 @@ function efi:get_backend(instance) end
|
|||||||
---@class CAN
|
---@class CAN
|
||||||
CAN = {}
|
CAN = {}
|
||||||
|
|
||||||
-- get a CAN bus device handler first scripting driver
|
-- get a CAN bus device handler first scripting driver, will return nil if no driver with protocol Scripting is configured
|
||||||
---@param buffer_len uint32_t_ud -- buffer length 1 to 25
|
---@param buffer_len uint32_t_ud -- buffer length 1 to 25
|
||||||
---@return ScriptingCANBuffer_ud
|
---@return ScriptingCANBuffer_ud|nil
|
||||||
function CAN:get_device(buffer_len) end
|
function CAN:get_device(buffer_len) end
|
||||||
|
|
||||||
-- get a CAN bus device handler second scripting driver
|
-- get a CAN bus device handler second scripting driver, will return nil if no driver with protocol Scripting2 is configured
|
||||||
---@param buffer_len uint32_t_ud -- buffer length 1 to 25
|
---@param buffer_len uint32_t_ud -- buffer length 1 to 25
|
||||||
---@return ScriptingCANBuffer_ud
|
---@return ScriptingCANBuffer_ud|nil
|
||||||
function CAN:get_device2(buffer_len) end
|
function CAN:get_device2(buffer_len) end
|
||||||
|
|
||||||
-- Auto generated binding
|
-- Auto generated binding
|
||||||
|
@ -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);
|
new_ScriptingCANBuffer(L);
|
||||||
*((ScriptingCANBuffer**)luaL_checkudata(L, -1, "ScriptingCANBuffer")) = scripting->_CAN_dev->add_buffer(buffer_len);
|
*((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);
|
new_ScriptingCANBuffer(L);
|
||||||
*((ScriptingCANBuffer**)luaL_checkudata(L, -1, "ScriptingCANBuffer")) = scripting->_CAN_dev2->add_buffer(buffer_len);
|
*((ScriptingCANBuffer**)luaL_checkudata(L, -1, "ScriptingCANBuffer")) = scripting->_CAN_dev2->add_buffer(buffer_len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user