Using one serial port for MAVlink 2 communication and lua scripting

Hey guys,

My system involves a Pixhawk 4 that uses UART and MAVlink 2 packages to send IMU, channel and arming info to a Teensy. The Teensy uses this info to control multiple motors, and sends RPM values back for the Pixhawk. Using lua, I can then use the RPMs to calculate some variables and move some servos to keep the system stable.

My issue is that I am unable to use the same UART (TELEM1) to send and receive the data. Is it possible to either send MAVlink packages within the lua scripting, allow the lua script to monitor a serial port that is in use, or to mirror the data being received by TELEM1 onto a separate port?

If not, is there any robust way I can package the data I need and send it through lua scripting? MAVlink has been great with its heartbeat information, I’m hesitant to throw it to the side.

Many thanks