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

Function lua_get_SocketAPM

libraries/AP_Scripting/lua_bindings.cpp:928–946  ·  view source on GitHub ↗

allocate a SocketAPM */

Source from the content-addressed store, hash-verified

926 allocate a SocketAPM
927 */
928int lua_get_SocketAPM(lua_State *L) {
929 binding_argcheck(L, 1);
930 const uint8_t datagram = get_uint8_t(L, 1);
931 auto *scripting = AP::scripting();
932
933 auto *sock = NEW_NOTHROW SocketAPM(datagram);
934 if (sock == nullptr) {
935 return luaL_argerror(L, 1, "SocketAPM device nullptr");
936 }
937 for (uint8_t i=0; i<SCRIPTING_MAX_NUM_NET_SOCKET; i++) {
938 if (scripting->_net_sockets[i] == nullptr) {
939 scripting->_net_sockets[i] = sock;
940 *new_SocketAPM(L) = scripting->_net_sockets[i];
941 return 1;
942 }
943 }
944
945 return luaL_argerror(L, 1, "no sockets available");
946}
947
948/*
949 socket close

Callers

nothing calls this directly

Calls 2

scriptingFunction · 0.85
luaL_argerrorFunction · 0.85

Tested by

no test coverage detected