Not sure if this has being discussed before or if it is "normal" behavior. Or wondering if I am doing some wrong.
I have been working for a while in a fast arduino server similar to what matlab provides via the usb to serial interface, but much faster and more open, so some the scientists I work with but are not familiar with C++ can control sensors and different hardware from Matlab. One of the researches I work with wanted to use an alpha version to test in a project, and we found didn't communicate in an old basic laptop he brought. Otherwise works in over a dozen of much powerful computers I tried. I found that in this computer it takes nearly 10 seconds to open the serial port. After debugging for a while, I simplified to some as simple as:
void setup() {
Serial.begin(115200);
Serial.print("O");
}
void loop() {
}
Once the port is opened in the PC side, it is assigned a handle with flying colors (no errors). The Arduino Mega resets immediately (as expected) but takes around 9 seconds to finally start and be ready to send the O back. I even tap with a different computer with RealTerm on the TX pin.
I also moved this simple example code to a much powerful computer and still takes around a second same deal.
As this is computer variable, I was suspecting in the USB to Serial converter controlled by the PC driver, but not sure.
What is even more problematic is that if the PC side starts sending data to the arduino because thinks the port is happy opened, but still is not, now the arduino gets stuck until you stop plus another 10 secs before the port finally opens.
I found that because my PC side was doing just that, so the protocol sends a header after the port is opened, that never makes' it, so tries again, and again... In the faster computers this was not a problem because the server side had a 1 sec delay after opening the serial, but puting 10 sec now thinking in the slows computers would be bad.
SO what I did so far is to send a char after Serial.begin() on the server side as shown in my simple example above ('O'), and wait on the PC client whatever it takes before proceeding. Then flush the O and start protocol header....
Still wondering if I got some wrong, or if is a better driver fix or something, as 9 secs looks like an insane amount of time to open a serial port. In fact, I have being writing serial programs like this for ages, and I can't remember some this ugly.
Note that in the fastest computer still will take 1 sec to open, and if I send data before that second, the opening keeps getting postponed... Interestingly enough I can see the data that comes from the PC via the USB to serial converter to hit the ATMEL MEGA, while the same MEGA can't start. Almost looks like if it is resetting during that time, but it is not (checking with oscilloscope). So I only can think of the bootloader that is failing to come up in the MEGA until data at serial RX stops, no idea why.
Anyway, any feedback will for sure be appreciated!
Thank you.