Do you have a question? Post it now! No Registration Necessary
- Bernhard Holzmayer
October 11, 2006, 7:05 am

Hi fellows,
I'm confused about the different size aspects, when setting up a USB
transmission. Here's a brief example of what I want:
bulk_size is 512 bytes (USB 2.0) (endpoint->wMaxPacketSize)
data size is 1000 bytes
From LDD I learnt, that it should be possible to set up the URB so that all
data are delivered in one bunch and the core parts between the submission
and the completion callback do the division and transmissions in adequate
blocks.
So I want to hand over to the URB a buffer containing the 1000 bytes,
and receive an alertion (completion callback handler), when all 1000 bytes
are out.
To transmit 512 bytes, I would do this:
-------------------------
urb = usb_alloc_urb(0,GFP_KERNEL);
buf = usb_buffer_alloc (udev, bulk_size, GFP_KERNEL, &urb->transfer_dma);
memcpy(buf,data,bulk_size);
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(..), buf, bulk_size,
callback,dev);
urb->transfer_buffer_length = bulk_size;
usb_submit_urb(urb, GFP_KERNEL);
and then, in callback handler (or at least after that):
usb_buffer_free(udev, bulk_size, buf, urb->transfer_dma);
usb_free_urb(urb);
------------------------------
Please check the '?'s. What must be filled in? Are my guesses ok?
urb = usb_alloc_urb(0,GFP_KERNEL);
buf = usb_buffer_alloc (udev, ?data_size?, GFP_KERNEL, &urb->transfer_dma);
memcpy(buf,data,?data_size?);
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(..), buf, ?data_size?,
callback,dev);
urb->transfer_buffer_length = ?bulk_size?;
usb_submit_urb(urb, GFP_KERNEL);
and then, in callback handler (or at least after that):
usb_buffer_free(udev, ?data_size?, buf, urb->transfer_dma);
usb_free_urb(urb);
------------------------------
What happens after submission?
First packet goes out. And then?
Is the second packet (with the rest of the data) automatically set up and
submitted internally, before the callback handler is launched?
Or is any further action required from my side?
I'd appreciate, if anybody could shed some light onto this.
Bernhard
I'm confused about the different size aspects, when setting up a USB
transmission. Here's a brief example of what I want:
bulk_size is 512 bytes (USB 2.0) (endpoint->wMaxPacketSize)
data size is 1000 bytes
From LDD I learnt, that it should be possible to set up the URB so that all
data are delivered in one bunch and the core parts between the submission
and the completion callback do the division and transmissions in adequate
blocks.
So I want to hand over to the URB a buffer containing the 1000 bytes,
and receive an alertion (completion callback handler), when all 1000 bytes
are out.
To transmit 512 bytes, I would do this:
-------------------------
urb = usb_alloc_urb(0,GFP_KERNEL);
buf = usb_buffer_alloc (udev, bulk_size, GFP_KERNEL, &urb->transfer_dma);
memcpy(buf,data,bulk_size);
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(..), buf, bulk_size,
callback,dev);
urb->transfer_buffer_length = bulk_size;
usb_submit_urb(urb, GFP_KERNEL);
and then, in callback handler (or at least after that):
usb_buffer_free(udev, bulk_size, buf, urb->transfer_dma);
usb_free_urb(urb);
------------------------------
Please check the '?'s. What must be filled in? Are my guesses ok?
urb = usb_alloc_urb(0,GFP_KERNEL);
buf = usb_buffer_alloc (udev, ?data_size?, GFP_KERNEL, &urb->transfer_dma);
memcpy(buf,data,?data_size?);
usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(..), buf, ?data_size?,
callback,dev);
urb->transfer_buffer_length = ?bulk_size?;
usb_submit_urb(urb, GFP_KERNEL);
and then, in callback handler (or at least after that):
usb_buffer_free(udev, ?data_size?, buf, urb->transfer_dma);
usb_free_urb(urb);
------------------------------
What happens after submission?
First packet goes out. And then?
Is the second packet (with the rest of the data) automatically set up and
submitted internally, before the callback handler is launched?
Or is any further action required from my side?
I'd appreciate, if anybody could shed some light onto this.
Bernhard
Site Timeline
- » Driver installation
- — Next thread in » Embedded Linux
-
- » interruptible_sleep_on
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » Sieci raz jeszcze: PoE, światłowody, giga bit ethernet.
- — The site's Newest Thread. Posted in » Electronics (Polish)
-