Nach einem USB-Gerät schauen ob es online ist.
Verfasst: Dienstag 12. Mai 2026, 18:41
Hallo,
ich möchte nach einem bekannten USB-Gerät schauen ob es online ist und dann per /dev/ttyUSBxxx einbinden.
Es ist also Linux.
Meine Code sieht aktuell so aus.
Ich erkenne aktuell das mein Gerät off oder online ist.
Wie erkenne ich welche Schnittstelle zu verwenden ist, oder wie greife ich darauf zu. muss ich eigentlich immer /dev/ttyUSBxxx verwenden oder gibt es andere Wege?
dev.parent zeigt mir folgendes
DEVICE ID 1d6b:0002 on Bus 003 Address 001 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0x9 Hub
bDeviceSubClass : 0x0
bDeviceProtocol : 0x1
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x1d6b
idProduct : 0x0002
bcdDevice : 0x617 Device 6.17
iManufacturer : 0x3 Error Accessing String
iProduct : 0x2 Error Accessing String
iSerialNumber : 0x1 Error Accessing String
bNumConfigurations : 0x1
CONFIGURATION 1: 0 mA ====================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x19 (25 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0xe0 Self Powered, Remote Wakeup
bMaxPower : 0x0 (0 mA)
INTERFACE 0: Hub =======================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x9 Hub
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x0
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x4 (4 bytes)
bInterval : 0xc
Gruß Ralf
ich möchte nach einem bekannten USB-Gerät schauen ob es online ist und dann per /dev/ttyUSBxxx einbinden.
Es ist also Linux.
Meine Code sieht aktuell so aus.
Code: Alles auswählen
import usb.core
usbdevice = usb.core.find(idVendor=0x0403, idProduct=0x6001)
if usbdevice is None:
print ('Device not found')
else:
print ("Gerät online")
print(dev.parent)
Wie erkenne ich welche Schnittstelle zu verwenden ist, oder wie greife ich darauf zu. muss ich eigentlich immer /dev/ttyUSBxxx verwenden oder gibt es andere Wege?
dev.parent zeigt mir folgendes
DEVICE ID 1d6b:0002 on Bus 003 Address 001 =================
bLength : 0x12 (18 bytes)
bDescriptorType : 0x1 Device
bcdUSB : 0x200 USB 2.0
bDeviceClass : 0x9 Hub
bDeviceSubClass : 0x0
bDeviceProtocol : 0x1
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x1d6b
idProduct : 0x0002
bcdDevice : 0x617 Device 6.17
iManufacturer : 0x3 Error Accessing String
iProduct : 0x2 Error Accessing String
iSerialNumber : 0x1 Error Accessing String
bNumConfigurations : 0x1
CONFIGURATION 1: 0 mA ====================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x2 Configuration
wTotalLength : 0x19 (25 bytes)
bNumInterfaces : 0x1
bConfigurationValue : 0x1
iConfiguration : 0x0
bmAttributes : 0xe0 Self Powered, Remote Wakeup
bMaxPower : 0x0 (0 mA)
INTERFACE 0: Hub =======================================
bLength : 0x9 (9 bytes)
bDescriptorType : 0x4 Interface
bInterfaceNumber : 0x0
bAlternateSetting : 0x0
bNumEndpoints : 0x1
bInterfaceClass : 0x9 Hub
bInterfaceSubClass : 0x0
bInterfaceProtocol : 0x0
iInterface : 0x0
ENDPOINT 0x81: Interrupt IN ==========================
bLength : 0x7 (7 bytes)
bDescriptorType : 0x5 Endpoint
bEndpointAddress : 0x81 IN
bmAttributes : 0x3 Interrupt
wMaxPacketSize : 0x4 (4 bytes)
bInterval : 0xc
Gruß Ralf