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

Read data from serial port more quickly #22

Closed

Conversation

cortadocodes
Copy link
Member

@cortadocodes cortadocodes commented Dec 21, 2021

Summary

Read all data waiting on the serial port into an in-memory buffer each time the serial port is read from (instead of reading one or a few bytes at a time). When tests/test_packet_reader.py is run, this change provides a roughly 3x speed-up.

Contents (#22)

Enhancements

  • Read all waiting bytes from serial port into memory

Operations

  • Remove MacOS as a test runner

Testing

  • Improve info packets test

@time-trader
Copy link
Contributor

My serial port buffer still gets full when parsing data coming from Mics. I am not sure we get any improvement with this method.

@time-trader
Copy link
Contributor

time-trader commented Dec 23, 2021

I also ran a very "scientific" test:
Commented out parsing and persistence on this branch: Buffer gets full
Commented out parsing and persistence on main branch: Buffer never gets full

startMics
[2021-12-23 02:11:02,497 | INFO | data_gateway.packet_reader] Microphones started 
[2021-12-23 02:11:02,498 | INFO | data_gateway.packet_reader] 
Exiting sleep

stopMics
[2021-12-23 02:25:44,797 | INFO | data_gateway.packet_reader] Microphone data reading done
[2021-12-23 02:25:45,472 | INFO | data_gateway.packet_reader] Microphone data erasing done
[2021-12-23 02:25:45,473 | INFO | data_gateway.packet_reader] 
Entering sleep

@cortadocodes
Copy link
Member Author

My serial port buffer still gets full when parsing data coming from Mics. I am not sure we get any improvement with this method.

The improvement isn't sufficient to deal with microphones without also threading the gateway but it should be a more efficient way of reading. I think what I'll do is leave this branch and the previous threading branch open for now while I create a new branch off of main that only includes threading of the current (main branch) implementation of serial port reading. This will hopefully provide some clarity on the related issues here.

@cortadocodes
Copy link
Member Author

This has been superseded by #30

@cortadocodes cortadocodes deleted the enhancement/read-data-from-serial-port-more-quickly branch February 16, 2022 15:31
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

2 participants