Communicating with uart in Ardupilot

Hi developers
i want to read sensor data from UART port and send this data to MP via mavlink
i create custom message on mavlink and it work perfect
I’m really confused right now, and I don’t know how to read data from UART and send it via MAVLink. Also, I’m unsure which function I should add to which file, or if I need to create a new file for this task?
The sensor needs to receive an activation command in order to respond.
“Could you give me some advice or examples?”
can some one tell me how can i create driver for my sensor and how can i use this?
Note:I don’t want to use Lua scripts to do this.

Then you need to write an uart driver, it is much more involved process when done in C++ than when using Lua. It also is more likely to bring the vehicle down.

2 Likes

Are you saying that if I write a driver for the sensor, it will have more processing?
Because I might have to use weaker boards

No, writing the code in Lua is easier but it needs more resources to run (IIRC F405 doesn’t have enough memory to run scripting, but please check if you have SCR_ENABLE). Writing entirely new drivers in C++ is significantly harder because you have to put code in a few places to run initialization and then periodically read the sensor data but it will take significantly less CPU resources onboard.

1 Like

ok now you can help to write my custom driver ?

which function I should add to which file, or if I need to create a new file for this task?