From: Wander L. <wan...@gm...> - 2010-01-17 23:25:50
|
What does this expression mean: (0x03 << 8) | var ? I could not see it in the Python code... Wander 2010/1/17 Henning Spille <h.s...@go...>: > Hi there, > > i'm trying to use this multi-plug (http://www.nw-s.net/images/sispm.jpg) with pyusb. I already used it form libusbJava which is based on the libusb from linux. > As it was no problem for me to get it working in java, i'm struggling with python. Well, i'm new to python (actually these are my first few lines of code) but i guessed it is more an pyusb related problem - caused by me. > > I hoped i could convert (manually for sure) the code from libusbJava to pyusb, but it does not work - yet. I attached some lines of code, dmesg output and lsusb --verbose info, but i don't know if it is necessary. Please can someone have a look at the controlMsg translation: > > Java Code: > > int reqtype = 0x21; > // USB_DIR_OUT + USB_TYPE_CLASS + > // USB_RECIP_INTERFACE /*request type*/ > int request = 0x09; // writing > byte var = (byte) (3 * plugNumber); > int index = 0; > byte _on = 0x03; > byte _off = 0x00; > switchTo = _on; > byte buffer[] = { var, switchTo }; > int timeout = 250; > int size = 2; > if (LibusbJava.usb_control_msg(handle, reqtype, request, (0x03 << 8) > | var, index, buffer, size, timeout) < 0) ..... > > My pyUsb Translation: > > > on = 0x03 > off = 0x00 > timeout = 250 > try: > print "Trying to switch" > var = (3 * plugNumber) > reqBuffer = [0] * 2 > reqBuffer[0] = var > reqBuffer[1] = off > print "Bytes to write: " + str(reqBuffer) > written = handle.controlMsg(0x21, 0x09, reqBuffer, value=0, index=0, timeout=250) > print "Bytes written: " + str(written) > except Exception, err: > print >> sys.stderr, err > handle, device = None, None > > > > The code works, no error in dmesg or elsewhere, but nothing happends at the device - so i guess there is something wrong somewhere. Can i somehow debug the communication? > > Would be nice if someone has some minutes to help me, > > Regards, > > Henning > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Pyusb-users mailing list > Pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyusb-users > > |