Commit Graph

81 Commits

Author SHA1 Message Date
Thomas Watson a077e4a3ed AP_Scripting: introduce serial device simulation support
Allows a script to simulate a device attached via any serial protocol.
The script can read and write data and have it handled according to the
protocol as if exchanged over a serial port. The script can then do
protocol translation, data filtering and validation,
hardware-in-the-loop simulation, experimentation, etc., especially in
combination with the scripting protocol which lets the script itself
handle an attached device and so interpose any communication.
2024-06-27 12:00:18 +10:00
Thomas Watson c18f9f733e AP_Scripting: add writestring for serial
Enables more efficient scripting.
2024-06-27 12:00:18 +10:00
Thomas Watson d93aa15f2a AP_Scripting: refactor serial readstring
Using `luaL_Buffer` avoids the need for any heap allocation in the
common case (count <= 512 bytes) and avoids stressing out the system
heap for large reads, instead using the script heap.

Zero net flash usage change.
2024-06-27 12:00:18 +10:00
Thomas Watson e18449b1b8 AP_Scripting: use generic access userdata for serial ports
Adding another layer instead of just exposing UARTDriver bindings allows
substitution of the different functions for device simulation later.

Also take the opportunity to rework the docs a little.
2024-06-27 12:00:18 +10:00
Iampete1 cc99ebf872 AP_Scripting: allow logging lua boolean with uint8 format `B` 2024-06-25 11:01:10 +10:00
Iampete1 1c26c241f1 AP_Scripting: add uint64 userdata 2024-06-18 10:37:13 +10:00
Andrew Tridgell a2459c6e61 AP_Scripting: use NEW_NOTHROW for new(std::nothrow) 2024-06-04 09:20:21 +10:00
Iampete1 95a5169439 AP_Scripting: CAN: `get_device` and `get_device2` return nil if no driver is configure with the correct protocol 2024-05-07 09:48:10 +10:00
Iampete1 b7dd432409 AP_Scripting: allow loading moduels from ROMFS 2024-02-27 10:17:43 +11:00
Andrew Tridgell f8097379cb AP_Scripting: prevent a code path to abort() in scripting
if scripting can't find an error handler it can call abort(). We don't
ever want to do that in ArduPilot
2024-02-21 12:09:48 +11:00
Andrew Tridgell 7b36adf49d AP_Scripting: prevent re-use of closed socket
this prevents a null pointer dereference after a close of a network
socket
2024-02-13 12:40:14 +11:00
Andrew Tridgell efac52136b AP_Scripting: fixed memory leak in sendfile()
this leaked the SocketAPM on each sendfile() call, we now rely on the
script calling close(). The net_webserver.lua is already using close()
correctly, this change just makes close able to find the socket
2024-01-08 13:01:02 +11:00
Andrew Tridgell a841e9c109 AP_Scripting: don't throw an exception on out of sockets in accept()
normal lua sockets don't throw an exception on accept, it just returns
nil
2024-01-03 12:14:47 +11:00
Andrew Tridgell 213cdcef4b AP_Scripting: use SocketAPM_native 2024-01-03 12:14:47 +11:00
Peter Mullen a83ed6b730 AP_Scripting: Add LUA interface to access Range Finder state 2024-01-02 11:31:02 +11:00
Andrew Tridgell 75217ec1e6 AP_Scripting: added readstring for uarts
this is much more efficient than reading a byte at a time
2023-12-12 07:42:15 +11:00
Andrew Tridgell ffb7328ede AP_Scripting: review fixes
thanks Pete!
2023-12-11 18:00:38 +11:00
Andrew Tridgell 90c12d4db3 AP_Scripting: added stat() binding for filesystem 2023-12-11 18:00:38 +11:00
Andrew Tridgell 1e1255c8f0 AP_Scripting: added sendfile() API on sockets 2023-12-11 18:00:38 +11:00
Andrew Tridgell 3446ff78d7 AP_Scripting: added isdirectory() 2023-12-11 18:00:38 +11:00
Andrew Tridgell 9065baa329 AP_Scripting: added bindings for SocketAPM 2023-12-11 18:00:38 +11:00
Iampete1 105801c5b0 AP_Scripting: add support for dependencty on manual methods, remove handling of mission commands without AP_Mission 2023-10-17 10:23:20 +11:00
Iampete1 fc68bf8979 AP_Scripting: don't include CAN support on periph if there is only one CAN port 2023-10-17 10:23:20 +11:00
Iampete1 a068569f8a AP_Scripting: add basic print 2023-10-04 18:34:08 +11:00
Iampete1 7bbd4a7c7d AP_Scripting: add some missing dependencies 2023-09-26 11:29:42 +10:00
Iampete1 ceca374f23 AP_Scripting: add MAVLink command long and ack examples 2023-07-04 10:20:42 +10:00
Iampete1 1c5f3c708a AP_Scripting: add new mavlink binding to block commands 2023-07-04 10:20:42 +10:00
Iampete1 529fb83ce3 AP_Scripting: change mavlink to `:` access to match everything else, return timestamp as uint32 2023-07-04 10:20:42 +10:00
Peter Barker d519ab604e AP_Scripting: allow AP_SCRIPTING_ENABLED to come from hwdef files 2023-06-09 16:10:52 +10:00
bugobliterator 06b5400d0b AP_Scripting: use get_uint32 instead of luaL_checkinteger 2023-05-24 19:03:28 +10:00
bugobliterator 28d49834c0 AP_Scripting: do semaphore lock when sending mavlink message from lua 2023-05-24 19:03:28 +10:00
bugobliterator d056a33dca AP_Scripting: use _chan to mark the methods that are mavlink channel based 2023-05-24 19:03:28 +10:00
bugobliterator 076d00fd1e AP_Scripting: add mavlink support to scripting 2023-05-24 19:03:28 +10:00
Michael du Breuil 598919d8ad AP_Scripting: Support sending MAVLink buffers from scripts 2023-05-24 19:03:28 +10:00
bugobliterator 306b14d8dc AP_Scripting: add require with sandbox inheritence 2023-04-28 12:36:08 +10:00
Peter Barker b167e19bb6 AP_Scripting: move and rename CAN Driver_Type enumeration 2023-04-20 08:53:46 +10:00
Iampete1 a021489580 AP_Scripting: lua_bindings: use local varable for AP_Scripting, don't get every time 2023-03-05 09:42:05 +11:00
Iampete1 54a9239e62 AP_Scripting: fix PWMSource deletion crash 2023-03-05 09:42:05 +11:00
Iampete1 c5c7863829 AP_Scripting: add bindings for E-stop, Interlock and Safety state 2023-02-07 10:24:18 +11:00
Andrew Tridgell ea89f04a56 AP_Scripting: script switching system
Co-authored-by:Henry Wurzburg (hwurzburg@yahoo.com)
2023-01-04 16:20:12 +11:00
Iampete1 f0c1673b62 AP_Scripting: bindings: logger: support more formats 2023-01-03 10:45:51 +11:00
Andrew Tridgell afc1a38b73 AP_Scripting: use luaM_malloc instead of allocf
handles GC if needed automatically
2022-12-15 07:17:06 +11:00
Andrew Tridgell ff6d9a12a4 AP_Scripting: try a gc on alloc fail in logging 2022-12-15 07:17:06 +11:00
Iampete1 0d0718c259 AP_Scripting: dont check objects that are expected to be null 2022-11-29 10:33:31 +11:00
Iampete1 6086402528 AP_Scripting: use helpers for full range return types to save flash 2022-11-15 10:33:51 +11:00
Iampete1 1547c65ff3 AP_Scripting: bindings: logging: add flag to copy format strings 2022-11-08 10:49:43 +11:00
Iampete1 d0f527369d AP_Scripting: remove type specific out of range warnings 2022-11-01 17:03:50 +11:00
Iampete1 06712c9f0b AP_Scripting: rework arg checks to save flash 2022-11-01 17:03:50 +11:00
Iampete1 5db30b75e7 AP_Scripting: logging: move to char buffer from lua buffer 2022-10-25 10:09:14 +11:00
Iampete1 cb34895cfa AP_Scripting: add maunal i2c binding allowing read of sequentual registers 2022-09-15 12:40:04 +10:00