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 issues from #9 -- increase select time, replace invalid firmware string #19

Closed
wants to merge 3 commits into from

Conversation

eode
Copy link
Contributor

@eode eode commented Dec 16, 2019

The select call has been increased to 0.2 0.5 seconds, which stops the issue originally mentioned in #9 - "Cannot read firmware from device".

A second issue is brought up in #9 - Sometimes the returned firmware string is V3.3 instead of TEMPerX_V3.3. This workaround simply replaces V3.3 with the full TEMPerX_V3.3 string retries when the V3.3 string is encountered.

When the replacement is used, a warning is issued. This goes to stderr, and doesn't interfere with piping the output of the script.

Reproduction

If you haven't applied the fix yet and are attempting to verify the bug's existence:

  • use the TEMPer2 device
  • 413d:2107 vendor/product ids
  • TEMPerX_V3.3
  • internal and external temperature sensors
  • executing temper.py once a second causes the issue to be much more frequent
  • Raspberry pi 3b -- issues may also occur with other hardware, but this is what I'm testing on.

Example

Using xonsh:

import time

while True:
    ./temper.py
    time.sleep(1)

These apply only to 413d:2107 Product/Vendor IDs:

Addresses missing hw response that appears to be race with slow hardware.
Assumes incomplete firmware ID string "V3.3" should be "TEMPerXV3.3"
@eode eode changed the title Fix issues from #9 -- increased select time, replace invalid firmware string Fix issues from #9 -- increase select time, replace invalid firmware string Dec 16, 2019
@eode
Copy link
Contributor Author

eode commented Dec 16, 2019

Changes

  • Firmware read select timeout time was bumped from 0.2 to 0.5 since read failure was still occurring (although rarely).
  • Retry by a simple recursion if the V3.3 string is encountered.
    • Retry is probably better than replacing V3.3 with TEMPerXV3.3, since it's possible the bug may be encountered on other TEMPer hardware (that would return something other than TEMPerXV3.3).
    • Since the invalid responses are infrequent, retrying until a valid response occurs is ok, and simple recursion suffices to guarantee a response.
  • No longer warns when the issue is encountered.

@nigels-com
Copy link
Contributor

I think that the number of retries ought to be bounded. That's why #16 uses a loop rather than recursion. The other advantage of #16 is that it seems to tolerate a smaller timeout for the select. (Raspberry Pi model B tested).

@eode
Copy link
Contributor Author

eode commented Jan 2, 2020

On mine, (raspberry pi 3b) it times out very frequently, using #16.

If having bounded retries (rather than exiting on failure) is preferable, that's fine. But the original issue that brought this up (Issue #9), using #16, is not solved on mine without a select time of at least 0.2 (and even that times out sometimes).

@eode
Copy link
Contributor Author

eode commented Jan 2, 2020

#16 now handles the same issues. I'll close this.

@eode eode closed this Jan 2, 2020
mccwdev pushed a commit to mccwdev/temper that referenced this pull request Nov 21, 2023
Add support for TEMPerF1.2 firmware
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