Hi there,
I have an external sensor for my drone project. I am trying to use a Lua Script to read out the Serial Port of my Pixhawk 4. To boot the sensor the Pixhawk has to send the command @4D001F via UART to the sensor, after that it should periodically read the data from the sensor and send it to the GCS.
I have written a script, but it doesen´t work and honestly I don´t really know what i am doing, this is all new to me.
It would be huge for me, if someone with experience at Lua Scripting could look through my script and give me clues what I have to change.
Currently my script reads:
local port = serial:find_serial(0)
port:begin(115200)
port:set_flow_control(0)
if port:available() > 0 then
gcs:send_text(0, “@4D001F”)
end
function spit ()
if port:available() > 0 then
read = port:read()
gcs:send_text(0, read)
end
gcs:send_text(0, read)
return spit, 1000
end
return spit, 1000
Thank you in advance
I have an external sensor for my drone project. I am trying to use a Lua Script to read out the Serial Port of my Pixhawk 4. To boot the sensor the Pixhawk has to send the command @4D001F via UART to the sensor, after that it should periodically read the data from the sensor and send it to the GCS.
I have written a script, but it doesen´t work and honestly I don´t really know what i am doing, this is all new to me.
It would be huge for me, if someone with experience at Lua Scripting could look through my script and give me clues what I have to change.
Currently my script reads:
local port = serial:find_serial(0)
port:begin(115200)
port:set_flow_control(0)
if port:available() > 0 then
gcs:send_text(0, “@4D001F”)
end
function spit ()
if port:available() > 0 then
read = port:read()
gcs:send_text(0, read)
end
gcs:send_text(0, read)
return spit, 1000
end
return spit, 1000
Thank you in advance