MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lua_serial_writestring

Function lua_serial_writestring

libraries/AP_Scripting/lua_bindings.cpp:813–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

811#endif // AP_SCRIPTING_SERIALDEVICE_ENABLED
812
813int lua_serial_writestring(lua_State *L)
814{
815 binding_argcheck(L, 2);
816
817 AP_Scripting_SerialAccess * port = check_AP_Scripting_SerialAccess(L, 1);
818
819 // get the bytes the user wants to write, along with their length
820 size_t req_bytes;
821 const char *data = luaL_checklstring(L, 2, &req_bytes);
822
823 // write up to that number of bytes
824 const uint32_t written_bytes = port->write((const uint8_t*)data, req_bytes);
825
826 // return the number of bytes that were actually written
827 lua_pushinteger(L, written_bytes);
828
829 return 1;
830}
831
832int lua_serial_readstring(lua_State *L) {
833 binding_argcheck(L, 2);

Callers

nothing calls this directly

Calls 3

luaL_checklstringFunction · 0.85
lua_pushintegerFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected