Hayden Donald
52ba8e8513
AP_Scripting: Change serial depends HAL_GCS to AP_SERIALMANAGER
...
Serial bindings were dependant on HAL_GCS_ENABLED but this is not ideal, it should be dependant on AP_SERIALMANAGER_ENABLED so that serial can function without GCS
2024-07-31 08:27:34 +10:00
Thomas Watson
3a834e83c7
AP_Scripting: reference script environment directly
...
Referencing the original function to run is of questionable value and
the only user uses it to grab the script environent from the upvalues.
Instead, use a reference to the script environment table directly.
2024-07-30 10:33:56 +10:00
Thomas Watson
212256731f
AP_Scripting: improve object allocation efficiency
...
Make new_X return the new object instead of having to grab it to
configure it.
Saves ~1.3K.
2024-07-30 09:55:25 +10:00
Ian Burwell
6b4e11090c
AP_Scripting: Add BQ40Z shutdown example
...
This example intercepts PREFLIGHT_REBOOT_SHUTDOWN COMMAND_LONG's and if
param1==2, it shuts down the BQ40Z smart battery BMS. Otherwise it
passes through the COMMAND_LONG as a COMMAND_INT (this required updating
the gcs:run_command_int to return a MAV_RESULT rather than a bool).
2024-07-30 09:40:10 +10:00
Ian Burwell
9d34fa2a5e
AP_Scripting: Add I2C transfer bindings
...
This adds bindings for an I2CDevice's transfer() function, an example,
and removes the nil return hint from the get_device() docs as it never
actually returns nil.
2024-07-30 09:40:10 +10:00
Andrew Tridgell
7477c4e205
AP_Scripting: fixed remove call
...
need to use AP_Filesystem
2024-07-11 07:43:35 +10:00
Peter Barker
933aed5f91
AP_Scripting: add missing scheduler include
...
corrects compilation of cubeorange-periph-heavy
2024-07-09 07:40:03 +10:00
Peter Barker
e88d76d72d
AP_Scripting: rangefinder singleton requires AP_RANGEFINDER_ENABLED
...
.... or HAL_PERIPH_ENABLE_RANGEFINDER
2024-07-02 09:17:26 +10:00
Andrew Tridgell
38ca478178
AP_Scripting: added gcs:run_command_int() binding
2024-07-01 20:08:29 +10:00
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