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

Retry firmware query if payload seems implausibly small #16

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

nigels-com
Copy link
Contributor

@nigels-com nigels-com commented Nov 17, 2019

In relation to Issue #9

Bus 003 Dev 006 413d:2107 V3.3 Error: Unknown firmware V3.3: b'800108984e200000'

I had some success with TEMPer1F 413d:2107 that was alternating between TEMPerX_V3.3 and V3.3 as the firmware version.

This change tries ten times to read the firmware while 0 < length < 9

See the issue for further diagnostics.

@nigels-com
Copy link
Contributor Author

Showing the retry in action...

$ sudo cat /sys/kernel/debug/usb/usbmon/3u | grep ':3:006:'
ffff8bbec3e593c0 3943174349 S Ii:3:006:2 -115:8 8 <
ffff8bc25f5cccc0 3943232132 S Io:3:006:2 -115:8 8 = 0186ff01 00000000
ffff8bc25f5cccc0 3943236425 C Io:3:006:2 0:8 8 >
ffff8bbec3e593c0 3943312462 C Ii:3:006:2 0:8 8 = 56332e33 20202020
ffff8bbec3e593c0 3943312475 S Ii:3:006:2 -115:8 8 <
ffff8bc26564e000 3943412672 S Io:3:006:2 -115:8 8 = 0186ff01 00000000
ffff8bc26564e000 3943420471 C Io:3:006:2 0:8 8 >
ffff8bbec3e593c0 3943424434 C Ii:3:006:2 0:8 8 = 54454d50 6572585f
ffff8bbec3e593c0 3943424445 S Ii:3:006:2 -115:8 8 <
ffff8bbec3e593c0 3943496443 C Ii:3:006:2 0:8 8 = 56332e33 20202020
ffff8bbec3e593c0 3943496454 S Ii:3:006:2 -115:8 8 <
ffff8bc26564e0c0 3943596663 S Io:3:006:2 -115:8 8 = 01803301 00000000
ffff8bc26564e0c0 3943604451 C Io:3:006:2 0:8 8 >
ffff8bbec3e593c0 3943680457 C Ii:3:006:2 0:8 8 = 800108dc 4e200000
ffff8bbec3e593c0 3943680466 S Ii:3:006:2 -115:8 8 <
ffff8bbec3e593c0 3943781525 C Ii:3:006:2 -2:8 0
ffff8bbec3e593c0 3944598482 S Ii:3:006:2 -115:8 8 <

@nigels-com
Copy link
Contributor Author

In relation to discussion over on Issue #9

Linux PC

$ while true; do sudo ./temper.py; sleep 1; done
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.1C 75.3F - - - -
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.2C 75.5F - - - -
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.1C 75.4F - - - -
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.1C 75.4F - - - -
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.1C 75.4F - - - -
Bus 003 Dev 011 413d:2107 TEMPerX_V3.3 24.1C 75.4F - - - -
...

@bucklevision
Copy link

bucklevision commented Jan 21, 2020

Made both of these changes and updated the timeout from 0.2 to 0.5 and still get failures every other read when running
while true; do sudo ./temper2.py; sleep 5; done
on an RPi 3 B+

Just investigating, the regularity of it made me call hardware into question, checking dmesg it shows brownout on each successful read, subsequently returning rubbish. Will confirm with new PSU.

__ Update:
PSU swapped for a high current one, no improvement - power drop out doesn't happen but still get errors.

Output modified as I don't need all the bumf, but....
--@--:/home/pi# ./temper2.py
21.5 2020-01-21 21:01:39
--@--:/home/pi# ./temper2.py
21.5 2020-01-21 21:01:41
--@--:/home/pi# ./temper2.py
Traceback (most recent call last):
File "./temper2.py", line 434, in
sys.exit(temper.main())
File "./temper2.py", line 427, in main
results = self.read(args.verbose)
File "./temper2.py", line 345, in read
results.append({ **info, **usbread.read() })
File "./temper2.py", line 272, in read
return self._read_hidraw(self.device)
File "./temper2.py", line 180, in _read_hidraw
firmware = self._read_hidraw_firmware(fd, self.verbose)
File "./temper2.py", line 159, in _read_hidraw_firmware
raise RuntimeError('Cannot read device firmware identifier')
RuntimeError: Cannot read device firmware identifier

@nigels-com
Copy link
Contributor Author

@bucklevision Could you mention the specific Temper USB model and the output of lsusb? Thanks.

@bucklevision
Copy link

Sure, sorry, not very helpful!

It seems to happen with successive calls within 2ish seconds. Give it 5 and most of the time it's OK.

lsusb:
Bus 001 Device 005: ID 0c45:7401 Microdia TEMPer Temperature Sensor
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

output of /sys/kernel/debug/usb/devices
T: Bus=01 Lev=02 Prnt=02 Port=02 Cnt=02 Dev#= 5 Spd=1.5 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0c45 ProdID=7401 Rev= 0.01
S: Manufacturer=RDing
S: Product=TEMPerV1.4
C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid
E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=10ms

It's one of these:
https://pcsensor.com/usb-thermometers/gold-temper.html

However it was purchased from Amazon.

@urwen urwen merged commit 1c5d8ab into urwen:master Feb 4, 2020
@nigels-com
Copy link
Contributor Author

@bucklevision I filed Issue #20 to follow up for TEMPerV1.4 and RPi3 B+. There is a workaround, so far.

mccwdev pushed a commit to mccwdev/temper that referenced this pull request Nov 21, 2023
Update info on DOCKER and fix docker-compose config
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.

3 participants