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

fix: remove unnecessary ECC lock and improve bus check #234

Merged
merged 3 commits into from
Mar 28, 2023
Merged

Conversation

shawaj
Copy link
Member

@shawaj shawaj commented Mar 25, 2023

Issue

How

  • ECC lock not required on this check because all we are doing is checking the i2c address of the attached device.
  • persist a generated ECC location (from the i2c bus) to file to make get_ecc_location() function more efficient and to remove unnecessary calls to the i2c bus
  • additional tests for SWARM_KEY_URI_OVERRIDE and new "persist to file" feature

Screenshots

References

Ref: NebraLtd/helium-syncrobit#10
Ref: NebraLtd/helium-syncrobit#2

Checklist

  • Tests added
  • Cleaned up commit history (rebase!)
  • Documentation added
  • Thought about variable and method names

@shawaj shawaj requested a review from a team as a code owner March 25, 2023 10:48
@shawaj shawaj changed the title fix: remove ECC unnecessary ECC lock fix: remove unnecessary ECC lock Mar 27, 2023
@shawaj shawaj changed the title fix: remove unnecessary ECC lock fix: remove unnecessary ECC lock and improve bus check Mar 27, 2023
- ECC lock not required on this check because all we are doing is checking the i2c address of the attached device.
- persist a generated ECC location (from the i2c bus) to file to make get_ecc_location() function more efficient and to remove unnecessary calls to the i2c bus
- additional tests for SWARM_KEY_URI_OVERRIDE and new "persist to file" feature

Ref: NebraLtd/helium-syncrobit#10
Ref: NebraLtd/helium-syncrobit#2
hm_pyhelper/miner_param.py Outdated Show resolved Hide resolved
with open("eccfile", 'r') as data:
generated_ecc_location = str(data.read()).rstrip('\n')
if len(generated_ecc_location) < 10:
generated_ecc_location = None
Copy link
Contributor

Choose a reason for hiding this comment

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

it works but I always find it confusing reading python code that defines a variable in if control block and then uses it outside.

Copy link
Member Author

Choose a reason for hiding this comment

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

what would you suggest instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

declaration of variable before the control block is something that makes it much more readable.

Copy link
Member Author

Choose a reason for hiding this comment

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

generated_ecc_location = str(data.read()).rstrip('\n') is defined in the line above initially? Or am I misunderstanding what you mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

@pritamghanghas any clarification here?

Copy link
Contributor

Choose a reason for hiding this comment

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

nothing really. I was just pointing to the weird scoping in python. I had approved it. This is fine.

hm_pyhelper/miner_param.py Show resolved Hide resolved
@pritamghanghas
Copy link
Contributor

I don't think ecc_lock is required anywhere. I think the thought process behind that lock was flawed. It is used like it is an os semaphore while it is only a lock within the application.

No need to remove it though, I don't think it is hurting anything either.

@shawaj
Copy link
Member Author

shawaj commented Mar 27, 2023

I don't think ecc_lock is required anywhere. I think the thought process behind that lock was flawed. It is used like it is an os semaphore while it is only a lock within the application.

No need to remove it though, I don't think it is hurting anything either.

I think the reason we put it in was because it was clashing with itself when trying to run from different places and these collisions were causing unexpected failures. However...we haven't actually really tested gateway-mfr-rs stuff without the ecc lock, only original erlang based gateway_mfr IIRC. So probably it is better now.

Definitely only think it makes sense when we are actually performing operations on the ecc though, and not when we are just checking its address on the i2c bus. But as you say, if not causing any issues, probably easier to leave it in.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

2 participants