On Tue, May 16, 2000 at 12:50:27PM -0700, Dmitri wrote:
> On Tue, 16 May 2000, wrobell wrote:
> 
> > I have attached USB Magnetic Stripe Reader by IBM.
> > Its endpoint address is 0x83 and inteface number 2.
> > In specification I have defined some commands, which
> > can be sent to the MSR.
> 
> > I should send them via control pipe with USB_TYPE_VENDOR
> > set ie. with usb_control_msg? What recipient should be?
> > Interface, endpoint or device?
> 
> It should be in specification: VENDOR_xxx (device, i/f, e/p, other).
> If you don't know, just try.
OK. 

The command is sequence of bytes '0x00 0x20'. I am sendning
it to the device with:

--------
  setup=kmalloc(8, GFP_KERNEL);
  setup[0]=0x00;
  setup[1]=0x20;
  ret=usb_control_msg(data->dev,
      usb_sndctrlpipe(data->dev, 0),
      0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
      0x00, 0, setup, 2, HZ*4);
  dbg("usb_control_msg=%d", ret);
  kfree(setup);
--------

When I change USB_RECIP_DEVICE to USB_RECIP_ENDPOINT and index=0x83
or to USB_RECIP_INTERFACE and index=2, then usb_control_msg
returns -EPIPE (-32).

In the MSR specification:
--------
 The status bytes should be interrogated through an interrupt pipe. Status
 is sent to the host on the interrupt pipe after each command. If Status
 indicates that MSR data is available, then Status, Length of Data, and Data
 should be read from MSR in a feature report though the control pipe. When a
 card is swiped, the MSR sends an unsolicited message status to the host
 through the interrupt pipe. No unsolicited message is sent to the host when
 the MSR is initialized. 
--------

So after sending command '0x00 0x20' I try to read the status
through interrupt pipe:

--------
  usb_cmd=kmalloc(2, GFP_KERNEL);
  usb_cmd[0]=0x00;
  usb_cmd[1]=0x20;

  int_urb=usb_alloc_urb(0);
  FILL_INT_URB(int_urb, data->dev, usb_rcvintpipe(data->dev, 0x83),
      usb_cmd, 2, (usb_complete_t)msr_urb_complete, data, 4);
  dbg("submitting URB");
  ret=usb_submit_urb(int_urb);

  interruptible_sleep_on(&data->wait); // XXX

  dbg("submit URB return code %d and status %d", ret, int_urb->status);
  dbg("msr status %x %x", usb_cmd[0], usb_cmd[1]);

  usb_free_urb(int_urb);
  kfree(usb_cmd);
--------

So in two first bytes pointed by usb_cmd I should get device status
but it waits at line XXX. Removing that line gives me urb->status
equal to -EINPROGRESS.

There is msr_urb_complete function:
-------
  void msr_urb_complete(struct urb *purb) {
    struct msr_data *d=purb->context;
    dbg("msr_urb_complete: WAKE UP!");
    if (waitqueue_active(&d->wait))
      wake_up_interruptible(&d->wait);
    dbg("exit msr_urb_complete");
  }
-------

Any suggestions?


  wrobell <[EMAIL PROTECTED]>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to