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: added readstring for uarts #25685

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Dec 3, 2023

this is much more efficient than reading a byte at a time

broken out from #25678

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.

I suspect there is a way to directly read into a lua string/buffer to remove the need for the extra allocation and copy. But I can't work it out, this method should work fine.

The lua docs say strings should be OK with trailing 0's but it might be a good idea to double check.

libraries/AP_Scripting/docs/docs.lua Outdated Show resolved Hide resolved
libraries/AP_Scripting/docs/docs.lua Outdated Show resolved Hide resolved
@tridge tridge force-pushed the pr-scripting-readstring branch 2 times, most recently from ef9135e to 93a3857 Compare December 8, 2023 07:13
this is much more efficient than reading a byte at a time
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.

Looks good, Thanks

@tpwrules
Copy link
Contributor

I suspect there is a way to directly read into a lua string/buffer to remove the need for the extra allocation and copy. But I can't work it out, this method should work fine.

See luaL_Buffer, in particular luaL_buffinitsize (returns a pointer where a string of at most a given length can be copied into) and luaL_pushresultsize (pushes the string with the length actually copied into that space).

@tridge tridge merged commit 75217ec into ArduPilot:master Dec 11, 2023
89 checks passed
@tridge
Copy link
Contributor Author

tridge commented Dec 11, 2023

See luaL_Buffer, in particular luaL_buffinitsize (returns a pointer where a string of at most a given length can be copied into) and luaL_pushresultsize (pushes the string with the length actually copied into that space).

thanks! I will try that as part of a rework I'm doing for speed in the web server

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.

None yet

4 participants