I have PC setup to talk to an arduino over one of the USB com ports. Both ends open the com port which presents a problem. If I start the arduino and then start the PC program, no data can be transferred. If I start the PC program first and then start the Arduino data moves between them just fine.
Unfortunately, since the arduino is powered by the same PC, it is powered up long before the PC comes to life. I have to start the PC program and the unplug and replug the arduino. Alternately, I can press the reset button on the arduino. If I stop the PC program and then restart it, I need to repower/reset the arduino again. There are no errors being generated on either end.
Is there a way to open either or both ends in some type of sharing mode or some other way to work around this?
I don't want to have to press the reset button or unplug-plug the arduino everytime I start the PC program.
The PC program is VB.Net and uses the standard .open() and the arduino uses Serial.begin(115200);
on powerup the arduino could wait for the PC host to prompt it, e.g. with '?' before starting to communicate any other character is ignored
void setup() {
// put your setup code here, to run once:
while(!Serial);
delay(100);
Serial.begin(115200);
delay(100);
while(Serial.read() != '?')
{ Serial.print("*"); delay(500); }
Serial.println("connected");
}
on systems where I may have several devices connected with COM ports the PC program (I usually use C#) attempts to open each port in turn and sends a '?' - the device would then send a message indicating which device it is, e.g. "Arduino Temperature Sensor 1"