Skip to content

Runtime.serial_bytes_available: return count instead of bool#9141

Merged
tannewt merged 2 commits intoadafruit:mainfrom
dhalbert:serial_bytes_available
Apr 5, 2024
Merged

Runtime.serial_bytes_available: return count instead of bool#9141
tannewt merged 2 commits intoadafruit:mainfrom
dhalbert:serial_bytes_available

Conversation

@dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Apr 4, 2024

Change supervisor.Runtime.serial_bytes_available to return the number of available bytes instead of just a True or False. Since 0 is False-y, this works in the common case of if supervisor.runtime.serial_bytes_available:.

I looked in the Learn Guides and I only found one use of .serial_bytes_available, and it's exactly as above.

This was a much larger change than one might think because I did a refactor to reduce a bunch of identical common-hal/supervisor files to single files in supervisor/shared. So there is, net, a lot less code now.

@tannewt tannewt self-requested a review April 4, 2024 16:40
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

A couple functional questions. Thanks for cleaning this up!

@dhalbert dhalbert changed the title Runtime.serial_bytes_available: return count isntead of bool Runtime.serial_bytes_available: return count instead of bool Apr 4, 2024
@dhalbert dhalbert requested a review from tannewt April 4, 2024 19:35
@dhalbert dhalbert mentioned this pull request Apr 4, 2024
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you!

@tannewt tannewt merged commit fbd9a6e into adafruit:main Apr 5, 2024
@dhalbert dhalbert deleted the serial_bytes_available branch April 5, 2024 20:19
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.

runtime.serial_bytes_available should return count of bytes

2 participants