Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator: Lua: allow strings #868

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Conversation

IamPete1
Copy link
Member

This allows strings to be sent and received in AP with the generated parser.

Tested with:

local mavlink_msgs = require("MAVLink/mavlink_msgs")

local STATUSTEXT_ID = mavlink_msgs.get_msgid("STATUSTEXT")

local msg_map = {}
msg_map[STATUSTEXT_ID] = "STATUSTEXT"

-- initialise mavlink rx with number of messages, and buffer depth
mavlink:init(1, 10)

-- register message id to receive
mavlink:register_rx_msgid(STATUSTEXT_ID)

function update()
    local msg, chan = mavlink:receive_chan()
    if (msg ~= nil) then
        local parsed_msg = mavlink_msgs.decode(msg, msg_map)
        if (parsed_msg ~= nil) and (parsed_msg.msgid == STATUSTEXT_ID) then

            local ack = {}
            ack.severity = 0
            ack.text = "got msg: " .. parsed_msg.text

            mavlink:send_chan(chan, mavlink_msgs.encode("STATUSTEXT", ack))

        end
    end

    return update, 1000
end

return update()

@tridge tridge merged commit 0407b9f into ArduPilot:master Oct 23, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants