Open mglowinski93 opened 2 years ago
Looks like I need to publish a new release via pip, v0.0.5 doesn't include the latest changes.
The error you want to catch when a sensor is unplugged or unavailable is probably OSError
:
Traceback (most recent call last):
File "/home/pi/Documents/vl53l1x-python/python/VL53L1X.py", line 145, in _i2c_write
self._i2c.i2c_rdwr(msg_w)
File "/usr/local/lib/python3.9/dist-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
ioctl(self.fd, I2C_RDWR, ioctl_data)
OSError: [Errno 121] Remote I/O error
Distance: -1mm
I've already found workaround :) But thanks anyway, good that you aware about this issue.
Hi, I've a question about proper installation of this library.
For the first attempt I installed it by
pip install vl53l1x==0.0.5
. In this case, I noticed that debug information appears (see https://github.com/pimoroni/vl53l1x-python/issues/47) and that exceptions will not be raised when the device is not active (see below code snippet):That is something what I would like to avoid, in other words to fail the script when device is not available.
I know there is the logic for validating the sensor availability while creating object, but what in case it will become unavailable during measurements?
So I decided to build a package on my own. I've downloaded this repository and executed
python setup.py build
. I can see a libraryvl53l1x_python.so
file insidebuild
folder. Once I move VL53L1X.py and distance.py to build folder I can successfully communicate with the sensor andDEBUG
output is not printed. I guess because I've build it without-DDEBUG
flad as mentioned in https://github.com/pimoroni/vl53l1x-python/pull/39.Nevertheless, I still can't get the script failing when device is not available. So I've two questions: 1) Should i rather build package on my own or install it with pip? 2) How to make script fail when there is an exception?