IndexError: list index out of range
Opened this issue · 9 comments
Running fitbit.py:
Start _check_burst_response
received: ['a4', '09', '4f', '00', '3d', '81', '00', '00', '00', '00', '00', '00', '5e']
End _check_burst_response
['0xda', '0xfe', '0xe6', '0x4f', '0xbc', '0x24', '0xd9', '0x00', '0x00', '0x00', '0x33', '0x79', '0x02']
Time: 2012-06-24 13:49:46 Daily Steps: 217
['0x00', '0x00']
Traceback (most recent call last):
File "./fitbit.py", line 360, in <module>
sys.exit(main())
File "./fitbit.py", line 352, in main
device.parse_bank1_data(device.run_data_bank_opcode(0x01))
File "./fitbit.py", line 319, in parse_bank1_data
daily_steps = data[i+7] << 8 | data[i+6]
IndexError: list index out of range
Another one, probably related:
Start _check_burst_response
received: ['a4', '09', '4f', '00', '3e', '81', '00', '00', '00', '00', '00', '00', '5d']
End _check_burst_response
['0xf2', '0x91', '0xe8', '0x4f', '0x08', '0x01', '0x05', '0xe8', '0x4f', '0x00', '0xef', '0x91', '0x00']
Time: 2012-06-25 18:29:38
['0x00', '0x00']
Traceback (most recent call last):
File "./Python/libfitbit/python/fitbit.py", line 360, in <module>
sys.exit(main())
File "./Python/libfitbit/python/fitbit.py", line 337, in main
device.parse_bank2_data(device.run_data_bank_opcode(0x02))
File "./Python/libfitbit/python/fitbit.py", line 285, in parse_bank2_data
print "Time: %s" % (datetime.datetime.fromtimestamp(data[i] | data[i + 1] << 8 | data[i + 2] << 16 | data[i + 3] << 24))
IndexError: list index out of range
bank1 and bank2 don't have the same format on my device as on yours. I could make the parsing dependant on the firmware version or such, but I need to know which firmware version you have ... Is it documented somewhere ?
I think it's something like 2.13a?
I've got:
Firmware Version: 12
BSL Version: 4.14
APP Version: 4.14
Is that what you're talking about ?
Made it dependant on my own (4, 14), see benallard@322fe7b
At a closer look, what you called in the code the "firmware version" is called "deviceInfo.hardwareRev" in the fitbit web request. I do think this could be used to distinguish the Fitbit and the FitBit Ultra, beter than the app version or the BSL version ...
What's your's ?
I get the same error message about list index out of range. I have a fitbit ultra, rev 4.14 (displayed at boot up/reset).
I tried your commit above, and it fixed the problem. Can it be integrated into main, or does it cause problems with fitbit classic?
@alfs It just looks like the project maintainer has other priorities.
Actually, about this particular problem, I switched the decision bit from the software version to the hardware revision in a later commit: benallard@6f0248a , as I guess the hardware revision indicates us better if we are talking to a classic or to an ultra tracker.
Project maintainer has been moving, so yeah, other priorities is about right. (The mozilla-central commits are because I'm paid to do that :) )
I see this commit is in the #34 uber pull request. Unfortunately I wasn't paying attention and merged things backward (this is why I usually never use pull request merge buttons), so I'll need to fix up the patch to merge it. Might also take me a bit to code review 'cause there's kind of a lot going on there. I'll try to get to it soon though.