Re: read(2) always returns 0 when reading from /dev/usb/n.m.k bulk IN endpoint

2010-07-13 Thread Peer Stritzinger
Hi,

FYI: just tried using the short xfer ioctl, but the behavior didn't change.

  in = open (argv[0], O_RDONLY);
  ioctl(in, USB_SET_RX_SHORT_XFER, 1);
  n = read(in, buf, NBUF);

now trying libusb for this.

-- Peer

On Mon, Jul 12, 2010 at 10:41 PM, Peer Stritzinger  wrote:

> Hi,
>
> On Mon, Jul 12, 2010 at 8:20 PM, Hans Petter Selasky  > wrote:
>
>> On Monday 12 July 2010 19:22:28 Peer Stritzinger wrote:
>> > However the read always returns 0.
>> >
>> > Tried different buffer sizes etc.
>> Hi,
>>
>> Maybe you are missing to set the short transfer OK flag.
>>
>> Else I recommend using LibUSB.
>>
>> --HPS
>>
>
> Did'nt set this flag (not doing any ioctls on the ugen device at all).
>
> However I did try matching either the max packetlen, or the read buffer
> size with the actual bytes sent, so I thought it shouldn't matter.
>
> I'll move on to libusb and not waste any more time with the raw interfaces.
>
> Thanks
> -- Peer
>
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: read(2) always returns 0 when reading from /dev/usb/n.m.k bulk IN endpoint

2010-07-12 Thread Peer Stritzinger
Hi,

On Mon, Jul 12, 2010 at 8:20 PM, Hans Petter Selasky
wrote:

> On Monday 12 July 2010 19:22:28 Peer Stritzinger wrote:
> > However the read always returns 0.
> >
> > Tried different buffer sizes etc.
> Hi,
>
> Maybe you are missing to set the short transfer OK flag.
>
> Else I recommend using LibUSB.
>
> --HPS
>

Did'nt set this flag (not doing any ioctls on the ugen device at all).

However I did try matching either the max packetlen, or the read buffer size
with the actual bytes sent, so I thought it shouldn't matter.

I'll move on to libusb and not waste any more time with the raw interfaces.

Thanks
-- Peer
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: read(2) always returns 0 when reading from /dev/usb/n.m.k bulk IN endpoint

2010-07-12 Thread Hans Petter Selasky
On Monday 12 July 2010 19:22:28 Peer Stritzinger wrote:
> Hi,
> 
> on FreeBSD 8.0-RELEASE I try to read from a bulk IN endpoint device node
> with read(2).
> 
> The USB client it is talking to is a embedded controller with Cypress SX2
> USB client chip, enumeration goes quite well (SX2 does it itself) and its
> reported correctly on console.  The device nodes in /dev/usv/n.m.k appear
> for the control endpoint and two OUT and IN endpoints each.
> 
> I can write to one of the OUT endpoints with e.g. dd and what I read on the
> device is correct.
> 
> However I can't read any data from a corresponding IN endpoint:  What I
> doing is in a loop:
> 
>   n = read(in, buf, NBUF);
>   printf ("read-test: read %ld bytes\n", n);
> 
> this is run as root.
> 
> I'm watching the USB with a USB protocol analyzer, BTW its running in
> High-Speed.
> 
> As soon as the first read is done (and blocks) I see IN->NAK (device did
>  not write to the IN endpoint) polling on the USB.
> 
> When the device writes to the endpoint buffer I see a correct bulk IN
> transfer that is ACKed by the host with the analyzer.
> 
> However the read always returns 0.
> 
> Tried different buffer sizes etc.
> 
> Is this supposed to work as I'm using it.  I'm planning to go to libusb-1.0
> later, should I debug this with the /dev/usb/n.m.k node reading or proceed
> to libusb because my approach can't work anyway?
> 
> Best regards,
> Peer Stritzinger

Hi,

Maybe you are missing to set the short transfer OK flag.

Else I recommend using LibUSB.

--HPS
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


read(2) always returns 0 when reading from /dev/usb/n.m.k bulk IN endpoint

2010-07-12 Thread Peer Stritzinger
Hi,

on FreeBSD 8.0-RELEASE I try to read from a bulk IN endpoint device node
with read(2).

The USB client it is talking to is a embedded controller with Cypress SX2
USB client chip, enumeration goes quite well (SX2 does it itself) and its
reported correctly on console.  The device nodes in /dev/usv/n.m.k appear
for the control endpoint and two OUT and IN endpoints each.

I can write to one of the OUT endpoints with e.g. dd and what I read on the
device is correct.

However I can't read any data from a corresponding IN endpoint:  What I
doing is in a loop:

  n = read(in, buf, NBUF);
  printf ("read-test: read %ld bytes\n", n);

this is run as root.

I'm watching the USB with a USB protocol analyzer, BTW its running in
High-Speed.

As soon as the first read is done (and blocks) I see IN->NAK (device did not
write to the IN endpoint) polling on the USB.

When the device writes to the endpoint buffer I see a correct bulk IN
transfer that is ACKed by the host with the analyzer.

However the read always returns 0.

Tried different buffer sizes etc.

Is this supposed to work as I'm using it.  I'm planning to go to libusb-1.0
later, should I debug this with the /dev/usb/n.m.k node reading or proceed
to libusb because my approach can't work anyway?

Best regards,
Peer Stritzinger
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"