Send char array via serial in LUA scripting

Is it possible to send char arrays in LUA like I can in Arduino?
Here’s a line of the code in Arduino:
Serial1.print(-50);

I tried using port:write(-50), but that doesn’t work and according to the bindings file, it only takes unsigned ints.
There’s a lot of discussions on the forums about reading serial data, but not many about sending it. I have also tried sending the char codes in lua, but the slave device doesn’t recognize it. I know the slave devices serial connection is working because I can restart it and read out the chars in mission planner.

use it this way.

str = string.format("14.66526 35.7762 %.0f",  hdg)
if str ~= nil then
   for idx = 1, #str, 1 do
     port:write(str:byte(idx))
  end
end

1 Like