Unable to encode MAVLink Messages

I am trying to write a lua script that will encode the EFI_STATUS message but am running into some trouble. I am getting back NIL when I try and receive MAVLink messages, and nothing happens when I try and encode the EFI message. attached is my test script, as well as the definition for the EFI_STATUS message script. My file structure is as follows:

-Penguin EFI Reader DRAFT4: APM->scripts

-mavlink_msg_EFI_STATUS: APM->scripts->modules->MAVLink

What am I missing here? (disregard the CAN stuff at the top of the EFI Reader script, that is future work)
Penguin_EFI Reader_DRAFT4.lua (2.0 KB)
mavlink_msg_EFI_STATUS.lua (918 Bytes)

hey so in this case you’re ingesting sensor data, then putting that into a MAVLINK message to then send directly to the GCS? I guess this means that data is not logged on Ardupilot?

So I am ingesting EFI status data via CAN and want to encode the EFI_STATUS mavlink message with that data so I can create a GUI that will display on Mission Planner (a quick python script) so the user can see the data quickly. I was having trouble using the CAN data directly to create the GUI so I thought a more seamless path would be to encode the mavlink message since the python script tends to play more nicely with the mavlink messages. If you have any other suggestions on how to achieve I am very much open to it.

So bearing in mind I haven’t tried this - however, there’s a driver i’ve found which uses the EFI object exposed in LUA. By using this LUA efi object, your data will then be put into an actual ardupilot EFI instance, which is then logged properly and will be sent to the GCS via MAVLINK automatically, like normal Ardupilot things such as batteries etc. So you can use your existing code which takes in your CAN messages, then instead of putting them into a MAVLINK message, put them into the EFI object.

What sensor are you trying to ingest?

It is data coming from an Edge Autonomy ECU from a Penguin B VTOL. Serial connection to it wouldn’t work so I am going with CAN which appears to be functional. So if I am understanding that example correctly, “EFI_State” is its own mavlink message that I am creating on the Lua back end rather than trying to encode it on the front end with the python script?

Ah cool! I’ve seen one of the fixed wing versions before but not too closely. So that ECU CAN is it’s own protocol?
EFI_state links to the internal ardupilot EFI data type and system. Electronic Fuel Injectors — Plane documentation. There’s other examples of LUA drivers listed there actually which I hadn’t looked at, and may be of use!
So the EFI_state isn’t a mavlink message directly, it links to the internal data system then that system logs the data and then sends out EFI mavlink messages also.

It is normal CAN protocol as far as I can tell, but not made to be plug and play with any open source firmware (it might be made for Piccolo?).
So doing this on the back end with Lua will allow me to pull the EFI status into the GUI front end with the python script then? Just want to make sure I am understanding correctly here. Also thanks for all the help thus far!

Ah i seeee ok, bit of a pain :sweat_smile:. Yes, you’ll be able to decode the MAVLINK stream on the GCS and display it. Mission planner does support displaying EFI data so you can just do that, but yes can do custom applications too. have you written the LUA driver to decode the ECU messages yet?

yes it has been a pain haha. and yes I have a LUA script that can decode the CAN data but hadn’t use that data to build the “efi_state” just yet. I will build that out based on the HFE script you referenced. Thank you so much!

1 Like

good luck, let us know how it goes : )

1 Like