# libusb



## Barnon (Oct 26, 2020)

I am trying to use python to talk to usb devices.
It is not working very well, and I would like to call atention to this.
I used pip to install pyusb. Calling show_devics() twice will cause a segfault.

FreeBSD 12.1 AMD64
Python 3.7.9

```
python -c "from usb.core import show_devices; print(show_devices()); print(show_devices())"
DEVICE ID 0403:6014 on Bus 000 Address 010, Specified at interface
DEVICE ID 04d8:9012 on Bus 000 Address 009, Specified at interface
DEVICE ID 05e3:0608 on Bus 000 Address 008, Hub
DEVICE ID 1462:7c37 on Bus 000 Address 007, Specified at interface
DEVICE ID 093a:2510 on Bus 000 Address 006, Specified at interface
DEVICE ID 413c:2107 on Bus 000 Address 005, Specified at interface
DEVICE ID 0000:0000 on Bus 000 Address 004, Hub
DEVICE ID 0000:0000 on Bus 000 Address 003, Hub
DEVICE ID 0000:0000 on Bus 000 Address 002, Hub
DEVICE ID 0000:0000 on Bus 000 Address 001, Hub

Segmentation fault (core dumped)
```
I believe there is a problem with the usb implementatin in the FreeBSD kernel.
Can anyone shed some light on this please ? I am in over my head here.

Thank you,


----------



## George (Oct 26, 2020)

If you want to report a bug, I suggest bugs.freebsd.org.


----------



## diizzy (Oct 26, 2020)

First of all, don't use pip. Use ports/packages instead.

There are two USB related libraries ported,





						FreshPorts -- devel/py-libusb1: Pure-python wrapper for libusb-1.0
					

Pure-python wrapper for libusb-1.0 supports all transfer types, both in synchronous and asynchronous mode




					www.freshports.org
				



https://www.freshports.org/devel/py-pyusb/ (this seems to be the one you're trying to use)


----------



## tingo (Oct 26, 2020)

It works fine here:

```
$ freebsd-version -ku
12.1-RELEASE-p9
12.1-RELEASE-p9

$ sudo python3.7 -c "from usb.core import show_devices; print(show_devices()); print(show_devices())"
DEVICE ID 0000:0000 on Bus 002 Address 001, Hub
DEVICE ID 0000:0000 on Bus 005 Address 001, Hub
DEVICE ID 0000:0000 on Bus 003 Address 001, Hub
DEVICE ID 0000:0000 on Bus 000 Address 001, Hub
DEVICE ID 0000:0000 on Bus 006 Address 001, Hub
DEVICE ID 0000:0000 on Bus 001 Address 001, Hub
DEVICE ID 0000:0000 on Bus 004 Address 001, Hub
DEVICE ID 0bda:0158 on Bus 003 Address 002, Specified at interface
DEVICE ID 046d:c01d on Bus 004 Address 002, Specified at interface

DEVICE ID 0000:0000 on Bus 002 Address 001, Hub
DEVICE ID 0000:0000 on Bus 005 Address 001, Hub
DEVICE ID 0000:0000 on Bus 003 Address 001, Hub
DEVICE ID 0000:0000 on Bus 000 Address 001, Hub
DEVICE ID 0000:0000 on Bus 006 Address 001, Hub
DEVICE ID 0000:0000 on Bus 001 Address 001, Hub
DEVICE ID 0000:0000 on Bus 004 Address 001, Hub
DEVICE ID 0bda:0158 on Bus 003 Address 002, Specified at interface
DEVICE ID 046d:c01d on Bus 004 Address 002, Specified at interface
```


----------

