How to use Bulk Transfer in Delphi

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
winai
Posts: 4
Joined: Wed Jul 18, 2007 10:15 am

How to use Bulk Transfer in Delphi

Post by winai » Wed Jul 18, 2007 10:32 am

I download Powerswitch in Delphi and modify to my project
It work very good
Now I want to transfer data from my device in bulk transfer

Please Help me for sample code in bulk transfer

Thanks Christian,iphi and Yvo

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jul 19, 2007 9:51 pm

I have no idea about Delphi and how to use USB from there, but if you don't have very good reasons to use bulk transfers, I would recommend against them.

Bulk transfers are not allowed for low speed USB devices, but they are tolerated by Windows and most other operating systems. If you specify a bulk endpoint in your descriptor, the host polls aggressively, consuming 90% of the AVR's CPU time. This is probably not what you want.

If you have a choice, I would recommend that you send/receive your data in control transfers.

winai
Posts: 4
Joined: Wed Jul 18, 2007 10:15 am

Post by winai » Fri Jul 20, 2007 6:07 am

Thanks Christian

I want to transfer from my data 1 Mbyte to Host
How I can fast Transfer Please Help me for Guide line Idea or C-code

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jul 20, 2007 9:56 am

1 MB is quite a bit of data for a low speed device. You must expect a total transfer time of ~ 2 minutes.

I would recommend that you divide the data into chunks of 128 bytes (the driver allows up to 254, but you probably want a power of 2) and read these chunks with a control transfer. You can use the wIndex field of the request to address the chunk, unless it's a data stream anyway.

winai
Posts: 4
Joined: Wed Jul 18, 2007 10:15 am

Post by winai » Fri Jul 20, 2007 4:34 pm

OK
But I don't sure understand all right
In Application I use
usb_control_msg(udev, (USB_TVENDOR or USB_RDEVICE or USB_EP_IN), CMD_GET, 0, 0, buffer, sizeof(buffer), 5000);
to send control transfer by CMD_GET = My request , buffer = In Data , sizeof(buffer) = byte received

In Device I use
usbFunctionSetup(uchar data[8])
and Return 128 , usbMsgPtr = Pointter of My data

Please recommend me

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Fri Jul 20, 2007 6:45 pm

That looks OK to me. You may want to pass an index and a value after CMD_GET to further identify the block, but you don't need to.

If you don't want to spend the extra 128 bytes of RAM for the reply message, you can return -1 and have usbFunctionRead() called to obtain chunks of 8 bytes each.

winai
Posts: 4
Joined: Wed Jul 18, 2007 10:15 am

Post by winai » Fri Jul 20, 2007 7:39 pm

Thank a lot for your help

Post Reply