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

Error in calibration_offset function #6

Open
Sanazjd opened this issue Oct 6, 2020 · 2 comments
Open

Error in calibration_offset function #6

Sanazjd opened this issue Oct 6, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Sanazjd
Copy link

Sanazjd commented Oct 6, 2020

In calibration_offset, I constantly got this error:
File "/home/pi/py3env/lib/python3.7/site-packages/qwiic_vl53l1x.py", line 1564, in __i2cWrite
buffer.append( (data >> 8) & 0xFF )

I changed the source code in this part of the calibration_offset function:

AverageDistance = AverageDistance / 50

and added // instead of / and it seems like it solved the problem. Is this a bug or there is a mistake in my process?

@santaimpersonator santaimpersonator self-assigned this Feb 19, 2021
@santaimpersonator
Copy link
Contributor

Is there more to the error message?

It sounds like there is a mismatch in the number of bytes. Your fix using floor division to input an integer is probably the correct solution. I'd have to review the API manual for this sensor to double check.

Currently, I don't have hardware on hand... could you print out the offset [https://github.com/sparkfun/Qwiic_VL53L1X_Py/blob/master/qwiic_vl53l1x.py#L1408] variable and it's data type? Otherwise, I'll take a look at this issue when I get a chance to get into the office again.

@santaimpersonator santaimpersonator added the bug Something isn't working label Feb 19, 2021
@FuzzyBunnys
Copy link

Hi, I had the same issue with both the crosstalk and offset calibration functions. The full tracebacks from running the code are here:
Traceback (most recent call last):
File "chemical_tank.py", line 50, in
if(frickinlaser.calibrate_offset(TargetDistance) == None):
File "/usr/local/lib/python3.7/dist-packages/qwiic_vl53l1x.py", line 1409, in calibrate_offset
self.status = self.__i2cWrite(self.address, ALGO__PART_TO_PART_RANGE_OFFSET_MM, offset*4, 2)
File "/usr/local/lib/python3.7/dist-packages/qwiic_vl53l1x.py", line 1564, in __i2cWrite
buffer.append( (data >> 8) & 0xFF )
TypeError: unsupported operand type(s) for >>: 'float' and 'int'

Traceback (most recent call last):
File "chemical_tank.py", line 43, in
if(frickinlaser.calibrate_xtalk(TargetDistance) == None):
File "/usr/local/lib/python3.7/dist-packages/qwiic_vl53l1x.py", line 1455, in calibrate_xtalk
self.status = self.__i2cWrite(self.address, 0x0016, xtalk, 2)
File "/usr/local/lib/python3.7/dist-packages/qwiic_vl53l1x.py", line 1564, in __i2cWrite
buffer.append( (data >> 8) & 0xFF )
TypeError: unsupported operand type(s) for >>: 'float' and 'int'

In my case I simply edited the inputs to the i2c function by casting them to int, as in int(xtalk) and int(offset*4). Probably not the correct way to do it given possible rounding errors but it was a quick hack to confirm that it was a float/int issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants