I would like to dedicate one of the serial ports to sending a simple UART message that I have defined. Is there any documentation for how to configure this? A couple of ideas I have are:
To set the serial protocol to none for a specific port and then follow the example in libraries/AP_HAL/examples/UART_test/UART_test.cpp to configure the serial port to send my UART message.
Create a new Serial Protocol in AP. My protocol would be very simple but I’m not certain which files I will need to modify/create so insight into that would be very helpful.
Do either of these approaches seem reasonable or is there a better way?
While you might learn more by diving into the source code, modifying it is a bit of a can of worms.
Anything custom that you add will have to be added back into any updates that you wish to perform, which becomes a version control nightmare.
A Lua script can exist independently and will require little care and feeding once you have it working. Updating to a new firmware version is typically a non-issue, and the script will remain available on the SD card between updates.
Yes.
I recommend taking a look at libraries/AP_HAL/examples/UART_test/UART_test.cpp to so see how the uart write function is used. You might want to create a function or class utilizing what you’ve learned from UART_test.cpp and call it in one of the existing tasks scheduled in arducopter.cpp
You might also want to define your own serial protocol. You can look at AP_SerialManager.cpp and AP_SerialManager.h to see how this is done.