| 811 | #endif // AP_SCRIPTING_SERIALDEVICE_ENABLED |
| 812 | |
| 813 | int 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 | |
| 832 | int lua_serial_readstring(lua_State *L) { |
| 833 | binding_argcheck(L, 2); |
nothing calls this directly
no test coverage detected