Example #1
0
 def openByVendorIDAndProductID(self, vendor_id, product_id):
     handle_p = libusb1.libusb_open_device_with_vid_pid(self.context_p,
         vendor_id, product_id)
     if handle_p:
         result = USBDeviceHandle(self, handle_p)
     else:
         result = None
     return result
Example #2
0
    def initialisation(self):
        """
        initialisation de la liaison usb

        :return: un handle sur la liaison usb (self.handle)
        """
        print('Initialisation usb')
        libusb1.libusb_init(NULL)
        libusb1.libusb_set_debug(NULL, 3)
        self.handle = libusb1.libusb_open_device_with_vid_pid(NULL, self.my_vid, self.my_pid)
        libusb1.libusb_claim_interface(self.handle, 0)
        print('Initialisation usb  ........  ok')
Example #3
0
 def openByVendorIDAndProductID(self, vendor_id, product_id):
     """
     Get the first USB device matching given vendor and product ids.
     Returns an USBDeviceHandle instance, or None if no present device
     match.
     """
     handle_p = libusb1.libusb_open_device_with_vid_pid(self.__context_p,
         vendor_id, product_id)
     if handle_p:
         result = USBDeviceHandle(self, handle_p)
     else:
         result = None
     return result
Example #4
0
#GetID Python Port
import libusb1,os,sys,struct
from ctypes import *

VID = 0x08E2
PID = 0x0002
buf =  create_string_buffer(8)

libusb1.libusb_init(None)   
hdev = libusb1.libusb_open_device_with_vid_pid(None,VID,PID)   
libusb1.libusb_get_descriptor(hdev, 3, 3, buf, 8);

buf = bytearray(buf)
dog_id = struct.unpack("<I",buf[:3]+"\x00")[0]
dog_id += 0xC5C10 #Magic Value


print("DogID: %0#x" % dog_id)
print("Raw Data: %08X" % struct.unpack(">Q",buf)[0])     
libusb1.libusb_close(hdev);
libusb1.libusb_exit(None)