Main Site Documentation

USB Host In Pipe


#1

I am interfacing with a USB 2.0 device. When I read the data from the IN pipe the read takes 501ms to read < 4 bytes of data. Is this typical? Does anyone with good knowledge of the USB Host have an opinion as to if this is typical? I was expecting it be much faster.

Is there a way sink an event handler on the IN pipe so I do not have to poll it on an interval?

-AP


            byte[] usbData = new byte[USB_Pipe_In.PipeEndpoint.wMaxPacketSize];
            int count = 0;

            
            //Read every USB_READ_INTERVAL
            while (true)
            {
                Thread.Sleep(USB_READ_INTERVAL);

                try
                {
                    DateTime tis = DateTime.Now;
                    count = USB_Pipe_In.TransferData(usbData, 0, usbData.Length);
                    DateTime tie = DateTime.Now;
                    int diff = (tie - tis).Milliseconds;
                    Debug.Print("SPAN: " + diff.ToString());
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message + "\r\n" + ex.ToString());
                }

#2

USB read/write should be over 500KBytes per second. It really depends on the device you are interfacing. For example a USB mouse will NOT send more than 4 bytes per 10 miili second…


#3

Its does not really matter how much data there is to transfer. The transfers are typically small < 4 bytes, but when I try and read 1024k it takes the same amount of time. The read take 500ms which seems too long.


#4

What device are you using?


#5

A USB Thermal Printer…made by Seiko.


#6

Oh, this is default timeout. Try this:

USB_Pipe.TransferTimeout = 0; :wink:


#7

To complete Mike’s answer :

as a base for USB Host programming, you can take the XBox controller in the project page. Or, even though my modesty may suffer :-[ , my Phidgets project : (link removed)

You can see in these programs the following :

_IF1018_Pipe.TransferTimeout = 0;                  // recommended for interrupt transfers


#8

Now why didn’t I think of that? That was it. Thanks!

-AP