# Parameter is incorrect error with usb 2.0 but not with usb 3.0 with C# serial program

I've been struggling to understand an error that is happening. I've got a simple program that sends/receives bytes over serial, and up until yesterday I figured was working 100%.

Basically, the issue is that my program works perfectly with any USB 3.0 ports, but fails on all USB 2.0 ports. I am only using Windows, and tested on both versions 7 and 10. The software is written in C#, and the AVR side is an Arduino, using an adapter with a large 512Mbit Flash memory on it.

I found an issue once I tried it on my spare laptop, which doesn't have any USB 3.0 options, and as soon as the program tries to send the serial data to my external AVR it crashes with a "The parameter is incorrect" error. Googling that error brings up a few hundred thousand results, all with completely different issues, so that error is super generic.

I'm using Dtrenable and Rtsenable, as suggested in other posts. My baud rate is a standard 9600. Here's how I'm initializing it.

private void Init(string portName)
{
myport = new SerialPort(portName);
myport.BaudRate = 9600;
myport.Parity = Parity.None;
myport.DataBits = 8;
myport.StopBits = StopBits.One;
myport.Handshake = Handshake.None;
}


Portname is set in a different section where I pull the available COM ports, and Dtr / Rts are being enabled right before I open the port to send the data.

Again, this works flawlessly on USB 3.0 ports on any computer I've tested, but fails on every USB 2.0 port. I should note that the AVR device is being powered by the USB port, but draws less than 100ma.

Any help understanding this would be great, thanks!

EDIT: Just checked something, and it only seems to fail if the file size being transferred is over 4MBytes. Any file smaller than that seems to write fine, even on USB 2.0. Anything larger than that fails on USB 2.0, but works fine on 3.0 ports.