This script is currently broken and may not work correctly.
It is excluded from the default browse listing until the issue is resolved.
drivers
broken
ExampleDriver
Template for a Lua hardware driver that reads from a serial port.
| Version | 1.0.0 |
|---|---|
| Date | 2026-05-18 |
| Min firmware | 4.5 |
| Vehicle | copter, plane, rover |
/lua_ardupilot_scripts/drivers/ExampleDriver.lua
Download .lua
ExampleDriver
Description
ExampleDriver is a template for writing hardware drivers in Lua. It opens the
first scripting serial port (SERIALx_PROTOCOL = 28), reads available bytes,
and forwards a byte-count summary to the GCS every 100 ms.
Use this as a starting point when implementing a driver for a new peripheral.
Setup
- Set one of your serial ports to
SERIALx_PROTOCOL = 28(Scripting). - Set
SERIALx_BAUDto match your device (default 115200). - Copy
ExampleDriver.luatoAPM/scripts/on your SD card. - Reboot. The script will log received byte counts to the Messages tab.
Parameters
| Parameter | Description |
|---|---|
BAUD_RATE |
Serial baud rate (hardcoded in script, default 115200). |