Page 1 of 1

libusb

Posted: Mon Jan 20, 2025 8:19 am
by infratec
Since it was needed I wrote a wrapper for libusb, the original one:

https://libusb.info/

https://github.com/libusb/libusb/releases

For windows, choose the 7z file and copy the dll from VS2022 in the directory of your code.

I think in linux it is installed by default.

For windows there are some things which should be noted:

The basic stuff works out of the box, but if you want to access a device, this device needs to have a driver installed which is compatible to libusb.

To manage this, the easiest way is to use zardig:

https://zadig.akeo.ie/

With this tool you can install the WinUSB driver for your device of interrest.

Then you can 'open' the device with libusb.

For macOS you have to install libusb via

brew install libusb


I provide a zip file with:

libcurl.pbi (the wrapper)
listdevs.pb
testlibusb.pb
rbtarm.pb (a basic test for 1267:0000)

https://www.von-der-salierburg.de/downl ... eBasic.zip

Re: libusb

Posted: Mon Jan 20, 2025 10:31 am
by infratec
Added support for macOS

Re: libusb

Posted: Mon Jan 20, 2025 5:23 pm
by PeDe
Just a small correction that I noticed. The function 'libusb_strerror' returns a pointer to a UTF8 string.

Peter

Code: Select all

EnableExplicit

IncludeFile "libusb.pbi"

If libusb_init(#Null) >= 0

	Debug libusb_strerror(-1)

	libusb_setlocale("fr")
	Debug libusb_strerror(-1) ; ASCII
	Debug PeekS(_libusb_strerror(-1), -1, #PB_UTF8)
	
	libusb_exit(#Null)
EndIf

; [Debug] Input/Output Error
; [Debug] Erreur d'entrée/sortie
; [Debug] Erreur d'entrée/sortie

Re: libusb

Posted: Mon Jan 20, 2025 9:44 pm
by infratec
PeDe wrote: Mon Jan 20, 2025 5:23 pm The function 'libusb_strerror' returns a pointer to a UTF8 string.
Fixed.