Teensy 3.1 USB packet size

Status
Not open for further replies.

bph

New member
Is it possible to have the Teensy 3.1 deliver a packet size other than 64 bytes?

Ideally I would like to test a much larger packet size of 12008 bytes to simulate another USB device

I haven't found a means to modify the packet size though

Anyone had any luck doing this?
 
The USB standard specifies 64 bytes as the maximum packet size, with 12 Mbit/sec "full speed".

http://www.pjrc.com/teensy/beta/usb20.pdf

(chapter 5 would be the best place to read, for data flow info)

Ideally I would like to test a much larger packet size of 12008 bytes to simulate another USB device

No USB device could use such a large packet size. It simply is not supported by any USB hardware.

Even at 480 MBit/sec, the maximum packet size is 512 bytes.
 
thanks paul

thats very useful info

this usb stuff is a bit new to me and maybe i have my terminology wrong

would it make more sense for me to talk of a bulk transfer of 12008 bytes?

I know that we have a piece of hardware from which we receive a bulk transfer of 12008 bytes, maybe i am incorrect to refer to that as a 'packet'

I am trying to simulate that hardware with a teensy for testing purposes (i don't always have access to the hardware)

so far i have only been able to recieve a bulk transfer of exactly 64 bytes when using the teensy.

My host is an android smartphone with the teensy being the device (connected via OTG)

should i be able to get the teensy to transmit a bulk transfer containing 12008 bytes?

i am very new to the teensy/arduino so apologies in advance for any stupid questioins..

*update*

i've just tested this, bulk transfer read on the android side fails when trying to receive 12008 bytes, e.g. packetSize is set to 12008:

byte[] dataBytes = new byte[packetSize];
int read = deviceConnection.bulkTransfer(dataEndpoint, dataBytes,
dataBytes.length, BULK_RX_TIMEOUT);

works when packetSize is 64, fails when packet size is 12008, i.e. read returns -1 on fail as opposed to no. of bytes received

also works with packetSize is 128

I wonder if it is timing out? 12 MBit/s = 1.5 MByte/s, BULK_RX_TIMEOUT is 5000 ms

can 12008 bytes be transmitted in 5s? yes, we only need 2.4kbyte/s to get the data out in time so orders of magnitude within limits

code on teensy side is:

byte buf0[] = {
0x53, 0x78, 0xe8, 0x03, 0x96, 0x36, 0x07, 0x00,
0xee, 0x00, 0x81, 0xcd, 0xae, 0xab, 0xc6, 0x2f,
...
0x7b, 0xcd, 0x81, 0x30, 0x00, 0x40, 0x2a, 0x53,
};

a 12008 byte buffer

then:

void loop()
{
Serial.write(buf0, 12008);
}

couldn't be much simpler..

works when I only write 64 bytes of buf0, i.e.

Serial.write(buf0, 64);

but its not happy with 12008

update #2

maybe what i'm observing is a limit on arduino serial buffer size?
 
Last edited:
Status
Not open for further replies.
Back
Top