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

Properly rewrite VEDirect interfacer for Python3. #121

Merged
merged 3 commits into from Sep 23, 2020

Conversation

bwduncan
Copy link
Contributor

The main problem was trying to decode the checksum byte (0-255) as utf-8
(0-127 plus continuation bytes), so we have to store everything as bytes
until we are ready to decode it.

I also took the opportunity to rewrite a few things in a simpler / more
pythonic style. This might raise different exceptions when things go
wrong, but it is shorter and it should be simpler to understand. I
tried to add some helpful comments!

It's now 1am and I don't have hardware to test this. I would appreciate anyone looking over this with a beady eye!

The main problem was trying to decode the checksum byte (0-255) as utf-8
(0-127 plus continuation bytes), so we have to store everything as bytes
until we are ready to decode it.

I also took the opportunity to rewrite a few things in a simpler / more
pythonic style. This might raise different exceptions when things go
wrong, but it is shorter and it should be simpler to understand. I
tried to add some helpful comments!
Exit the read_serial loop if the data are bad. This will return to the
interfacer loop and try again in "pool_interval" time, instead of
waiting forever for valid data.
@TrystanLea
Copy link
Member

Hello @bwduncan I've been able to fix the conflicts here, should I merge this?

@bwduncan
Copy link
Contributor Author

Yes please, the code was quite broken so even if this doesn't work it's a worthwhile incremental improvement and I would much rather people are testing this than the previous code!

@TrystanLea TrystanLea merged commit 04dd7a3 into openenergymonitor:master Sep 23, 2020
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