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

AP_Scripting: add REPL applet #27311

Merged
merged 4 commits into from
Aug 5, 2024
Merged

Conversation

tpwrules
Copy link
Contributor

@tpwrules tpwrules commented Jun 16, 2024

Implements a reasonably comfortable REPL accessible over serial entirely as a loadable script. Also accessible using QGroundControl's MAVLink Console feature, if so configured.

Removes never-implemented SERIAL_CONSOLE_DEV_SHELL handling and saves a few dozen bytes on Cube Orange.

Tested in SITL and on the bench with a Cube Orange. Was able to run a couple examples through it.

Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! We really need a binding to get the baud rate for a serial port.

@tpwrules
Copy link
Contributor Author

Yeah, it would be nice, but it looked a bit troublesome. I also want coroutines and writestring, but I filed all that under future work.

The HAL always returns nullptr so the function always returns, which is
handled already by the default.
The only caller is now gone and nobody ever overrode it to do return
more than nullptr.
@tpwrules
Copy link
Contributor Author

tpwrules commented Aug 3, 2024

I've been using this a while and am quite happy with it. Seems to work reliably and has been very useful for my recent scripting PRs.

Added a few features and tweaked some things (including removing some vestigial code and saving a few bytes of flash). I think it would be cool for it to be merged for others to use.

@tridge
Copy link
Contributor

tridge commented Aug 3, 2024

looks nice!

Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per line lua check ignores are much less offensive that for per file, but it would be nice to not have to ignore anything.

libraries/AP_Scripting/modules/mavport.lua Outdated Show resolved Hide resolved
libraries/AP_Scripting/modules/mavport.lua Outdated Show resolved Hide resolved
libraries/AP_Scripting/applets/repl.lua Outdated Show resolved Hide resolved
libraries/AP_Scripting/applets/repl.lua Outdated Show resolved Hide resolved
Abstracts the MAVLink SERIAL_CONTROL message to be usable as a Lua port,
in particular the DEV_SHELL device supported by QGroundControl's MAVLink
Console.
Implements a reasonably comfortable REPL accessible over serial entirely
as a loadable script.

Also accessible over MAVLink using QGroundControl's MAVLink Console and
the new mavport module.
Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scripting stuff looks good, it would be nice not to have to ignore the checks on a few lines, but this is quite a advanced script, so maybe its OK.

@tridge tridge merged commit a164aba into ArduPilot:master Aug 5, 2024
94 checks passed
@tpwrules tpwrules deleted the lua-script-repl branch August 5, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants