Hello,
I recently started using the Arduino Due for a high-speed ADC project, and I need to be able to write ~3MBit/s to a PC with the overhead of the Arduino code to communicate with that ADC. I have been doing some testing of the native arduino speed using SerialUSB (arduino_USB_slow.ino), and have got communication to work with a simple python script using pySerial (forum won't let me attach file, but it's pretty braindead simple).
With increasing block size I am able to increase the data rate (from 1.22MBit/s writing one byte at a time to SerialUSB to 7.58Mbit/s using 8 bytes at a time). This is a trend I like to see, and I would happily use as large a block size as the hardware permits (which, if you know it from reading the chip's datasheet, would be great information to share below). However, if I try to send more than 8 bytes at a time with the SerialUSB.write() command (see the code below, it attempts to write 9 bytes), I get no data transferred over the serial port at all. My pySerial input buffer stays at 0 bytes after opening the port. There are no problems compiling the code, no problems uploading it, and no problems when trying to write 8 bytes. The problem only exists when I try to write more than 8 bytes (I've tried 9, 10, 16, none of them have worked).
There's no indication in the Serial library documentation of a limitation on the input byte array size, and as I understand it if the buffer isn't large enough, the command will just block further execution until the hardware buffer is refilled enough times to get through all the data. There doesn't appear to be any SerialUSB documentation at all in the official docs. Any thoughts? I'm stumped.
[EDIT: this happens whether I use SerialUSB.print() or SerialUSB.write()]
arduino_USB_slow.ino (374 Bytes)