This should never be called so there's not much to be gained from a
panic message. If it is, the call should be identifiable by the internal
error line number.
Fixes:
../../libraries/AP_Scripting/lua_bindings.cpp: In function 'int lua_AP_Vehicle_set_target_velocity_NED(lua_State*)':
../../libraries/AP_Scripting/lua_bindings.cpp:1240:23: error: 'check_AP_Vehicle' was not declared in this scope; did you mean 'check_AC_Fence'?
1240 | AP_Vehicle * ud = check_AP_Vehicle(L);
| ^~~~~~~~~~~~~~~~
| check_AC_Fence
compilation terminated due to -Wfatal-errors.
docs for set_target_velocity_NED()
add set_target_angle_and_rate_and_throttle() for precise vehicle control
manual binding for set_target_velocity_NED() to allow optional boolean
update docs for attitude control
malloc is kinda slow and we were failing to free the memory in tandem
with its original allocated size, causing Lua to believe we still had
the bytes allocated. This created misleading stats and unnecessary GC
pressure, but no actual leak.
Fix by using a stack buffer half the buffer size we use in other
functions but still big enough for the maximum possible log message.
Co-authored-by: jschall <mr.challinger@gmail.com>
The different size won't cause the `accept_msg_ids` array to be
reallocated, but it will still be zeroed up to its new size. If that's
bigger than the old one, then the heap gets corrupted, and mayhem and
destruction ensues.
Fix by only initializing the related data immediately on successful
allocation.
Push a dummy element on a dot call to make the stack look like the
generated bindings, which always expect the colon call (that pushes self
as the first argument) and the intended usage pattern.
Folds in `arg_offset = 1`. Note that none of these routines care about
the first argument as they were fine being called without it.
Avoids potential null pointer dereferences if a port write method can't
handle a null pointer when doing a zero length write. Also provides a
nice type error if something that can't be converted to a string is
passed.
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
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.
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).
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.
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.
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.
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.
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