From: Henning S. <h.s...@go...> - 2010-01-17 10:49:33
Attachments:
lsusbDmesgAndOtherOutput.txt
|
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 |
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 > > |
From: Henning S. <h.s...@go...> - 2010-01-18 10:58:50
|
Hi there, actually i do not really know what that value stands for. In the libUsbJava doc (found here:http://libusbjava.sourceforge.net/wp/res/doc/ch/ntb/usb/LibusbJava.html#usb_control_msg%28long,%20int,%20int,%20int,%20int,%20byte[],%20int,%20int%29 ) it is named "value" - well, got no idea what it does mean. '0x03 << 8 | var' means :0x08 shift by 8, bitwise or var' Does it help? Greetings from Germany, Henning Am 18.01.2010 um 00:25 schrieb Wander Lairson: > 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 >> >> > > ------------------------------------------------------------------------------ > 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 |
From: Wander L. <wan...@gm...> - 2010-01-18 11:07:31
|
No, no... I am asking what does this value mean for your device, because as far as I know, you should send it as the value parameter in the controlMsg method... :) 2010/1/18 Henning Spille <h.s...@go...>: > Hi there, > > actually i do not really know what that value stands for. In the libUsbJava doc > (found here: http://libusbjava.sourceforge.net/wp/res/doc/ch/ntb/usb/LibusbJava.html#usb_control_msg%28long,%20int,%20int,%20int,%20int,%20byte[],%20int,%20int%29 ) > it is named "value" - well, got no idea what it does mean. > > '0x03 << 8 | var' means :0x08 shift by 8, bitwise or var' > > Does it help? > > Greetings from Germany, > > Henning > > > > > Am 18.01.2010 um 00:25 schrieb Wander Lairson: > >> 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 >>> >>> >> >> ------------------------------------------------------------------------------ >> 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 > > |
From: Henning S. <h.s...@go...> - 2010-01-18 16:22:18
|
Hi, yes. Found the error. For sure the value is the "instruction" passed to the device - right? Now it works fine, cool! Don't know why i misunderstood that. Thank you a lot for helping! Regards, Henning Am 18.01.2010 um 12:07 schrieb Wander Lairson: > No, no... I am asking what does this value mean for your device, > because as far as I know, you should send it as the value parameter in > the controlMsg method... :) > > 2010/1/18 Henning Spille <h.s...@go...>: >> Hi there, >> >> actually i do not really know what that value stands for. In the libUsbJava doc >> (found here: http://libusbjava.sourceforge.net/wp/res/doc/ch/ntb/usb/LibusbJava.html#usb_control_msg%28long,%20int,%20int,%20int,%20int,%20byte[],%20int,%20int%29 ) >> it is named "value" - well, got no idea what it does mean. >> >> '0x03 << 8 | var' means :0x08 shift by 8, bitwise or var' >> >> Does it help? >> >> Greetings from Germany, >> >> Henning >> >> >> >> >> Am 18.01.2010 um 00:25 schrieb Wander Lairson: >> >>> 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 >>>> >>>> >>> >>> ------------------------------------------------------------------------------ >>> 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 >> >> > > ------------------------------------------------------------------------------ > 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 |