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
What i already can read from the device using pyusb:
python usb3.py 
Device: 007
  Device class: 0
  Device sub class: 0
  Device protocol: 0
  Max packet size: 8
  idVendor: 1204
  idProduct: 64787
  Device Version: 01.01
  Configuration: 1
    Total length: 27
    selfPowered: 0
    remoteWakeup: 0
    maxPower: 44
    Interface: 0
    Alternate Setting: 0
      Interface class: 3
      Interface sub class: 0
      Interface protocol: 0
Plug found!
<usb.Device object at 0x989edc8> 0x4b4L 0xfd13L>

lsusb --verbose gives:

Bus 002 Device 007: ID 04b4:fd13 Cypress Semiconductor Corp. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x04b4 Cypress Semiconductor Corp.
  idProduct          0xfd13 
  bcdDevice            1.01
  iManufacturer           1 Gembird Electronics
  iProduct                2 Gembird Silver Shield PM
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           27
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              150mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0 
      ** UNRECOGNIZED:  09 21 10 01 00 01 22 d9 00
Device Status:     0x0000
  (Bus Powered)


dmesg at connection:

[23184.808216] usb 2-1: new full speed USB device using uhci_hcd and address 7
[23184.957093] usb 2-1: configuration #1 chosen from 1 choice
[23185.022999] usbhid 2-1:1.0: couldn't find an input interrupt endpoint



------------------------------------------------------------------------------
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
Pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to