2012/1/25 bibek chitrakar <bibek.chitra...@gmail.com>: > I have modified my code a bit adding class. > Still the same problem. > Why cant I write into the device since the device has been detected. > Here's my code > > ######################################################## > > #!usr/bin/python > > import usb > import time > > class HardwareMonitor_printer(object): > def __init__(self, vendor_id, product_id): > self.device_found = False # True if device found > busses = usb.busses() # enumerate busses > self.handle = None > # print 'busses: ',busses > for bus in busses: > # print 'bus: ',bus > devices = bus.devices > # print 'devices: ',devices > for dev in devices: > if dev.idVendor == vendor_id and dev.idProduct == > product_id: # device matches > self.dev = dev > self.conf = self.dev.configurations[0] > self.intf = self.conf.interfaces[0][0] > self.endpoints = [] > for endpoint in self.intf.endpoints: > self.endpoints.append(endpoint) > > self.device_found = True > return > > def open(self): > if self.handle: > self.handle = None > try: > self.handle = self.dev.open() > self.handle.detachKernelDriver(0) > self.handle.detachKernelDriver(1) > self.handle.setConfiguration(self.conf) > self.handle.claimInterface(self.intf) > self.handle.setAltInterface(self.intf) > return True > except: > return False > > def write(self, ep , buff, timeout=100): > try: > return self.handle.interruptWrite(ep, buff, timeout) #return > bytes written > except usb.USBError as e: > print e > return 0 > > def read(self, ep, size, timeout=100): > try: > return self.handle.interruptRead(ep, size, timeout) # return > data read > except: > return [] > > def getDeviceName(self): > try: > for i in range (1, 4): > print self.handle.getString(i,25) > except IOError as e: > print e > > def endpoint(self): > return self.endpoints > > if __name__ == '__main__': > printer = HardwareMonitor_printer(0xdd4,0x1a8) > if printer.device_found: > printer.open() > printer.getDeviceName() > #: is there something wrong with the parameters ? > bytes_written = printer.write(1, [0x81], 1000) > time.sleep(1) > #: is this parameter right ? > bytes_read = printer.read(0x81, 64) > print 'rx data: ', bytes_read > else: > print 'device not found!!!' > > =============================== > I got this output. > > $ sudo python hardware_monitor_printer.py > CUSTOM Engineering S.p.A. > TG2480-H > Self Power Mode > error submitting URB: No such file or directory > rx data: [] > > =============================== > Please someone help me. I really need to > solve this. At least I need to send some hex > codes into the device. > > Thanks in regards. >
Are you sure the endpoint type is of interrupt type? What kind of device is that? -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users