OK, so I've been working on a project for a while that is using a 2560 Mega and interfaces through a 3rd party piece of software (that I don't control), via Serial. This software is cross platform and all my testing has been in linux and OSX where it has been fine.
Go to test in Windows though and the software won't connect. After many, many hours of playing around, there seems to be an issue with the initialisation of the Serial channel on the arduino. The software I'm interfacing is in Java and using rxtx for serial, but what I'm seeing is that there is about a 9 second delay between a serial session that this software starts and the arduino actually initially responding. I have confirmed this in multiple ways with a serial sniffer. Once this initial delay is over, the arduino responds just fine.
As the software I'm trying to interface with initialises it's connection by sending a command, waiting about 1.5s for a response and then shutting the connection down and reinitialising, it will never connect as the arduino will always be taking ~9 seconds after the serial connection is opened.
The other thing I've found is that, if I reset the arduino right after the serial connection is made, it fires up and starts working straight away, no delay.
The closest thing I've been able to find is in this post: http://forum.arduino.cc/index.php/topic,118635.0.html
It talks about it potentially being an enumeration issue in rxtx and links to another post where it is patched within the Arduino IDE serial monitor, but if this is indeed the same thing, the problem remains in the original rxtx code.
That's about as far as I've gotten. Has anyone else ever run into this and found a reasonable solution? It's going to cause major headaches for me if this can't run on Windows (again, linux and OSX are fine)
about a 9 second delay between a serial session that this software starts and the arduino actually initially responding.
That sounds like the bootloader starting up after the serial port opening resets the Arduino.
Can you have your sketch light up an LED or similar when setup runs so you can tell the sketch has started?
I know on my Windows machines, the Serial Monitor opening resets the connected board a couple of times.
I don't understand why you are not experiencing the same Arduino startup delay on Linux. There is certainly a delay on my Linux PC using RxTx and JSSC.
It is possible to disable the auto-reset feature on the Arduino but that can make it difficult to upload programs to it.
about a 9 second delay between a serial session that this software starts and the arduino actually initially responding.
That sounds like the bootloader starting up after the serial port opening resets the Arduino.
It's possible, but the issue isn't being experienced in the Arduino Serial monitor, so there is something going on with a 'standard' rxtx connection in java.
One further thing I've just noticed, when I open the serial line through this program (Which handily has a built in mini terminal which exhibits the same issue) the LED on pin 13 stays on for 7-9 seconds. It's not until this LED turns off that the serial comms will work. Strangely, if you keep sending serial data during this time, the delay before the LED goes off and the arduino starts responding goes up dramatically.
This same delay isn't seen on the Arduino serial monitor. The LED comes on, but only for maybe 1-2 seconds at most after a reset.
Ohh and one other thing... This delays isn't experienced when I just hit the reset button. I can actually make this software work by hitting the reset button during the time its trying to connect (When the pin13 LED is on) which seems to kick off the serial comms.
This long delay appears to only be seen when there is an auto reset as a result of this software opening the serial line.
OK, more playing and this is DEFINITELY an issue with rxtx. I took the patched version of rxtxSerial.dll from http://forum.arduino.cc/index.php/topic,46977.0.html and replaced the one in the software I am using. BAM! Up and running with no issues.
I wonder if this issue is something that can be addressed in rxtx as it's certainly a pain in this type of case.
I'm guessing from what you say that you want the Arduino to work with Windows on PCs that you can't control - hence an "automatic" or "no-intervention" solution is required ???
There are ways to temporarily disable the Arduino auto reset using a capacitor (better try Google rather than my poor memory of the details). You could see if that would get around the problem.
Would it be possible to use a Serial - TTL (aka FTDI) cable to communicate between the PC and the Arduino instead of the regular USB connection. That would allow you to bypass the Arduino reset mechanism. As well as the extra cost, the downside is that you would need to arrange a power supply for the Arduino.