code in Arduino to connect/disconnect serial communication
Posted: Wed May 27, 2015 6:36 pm
Hello,
I noticed that with the last MLP version, upon connecting (in any window, e.g., Time Plot, Monitor, Interface Panel or Connection Manager) after disconnecting the serial communication, the arduino sketch restarts from scratch as if it has just been loaded.
This somewhat confusing feature can nevertheless be useful as an error handling tool.
With this in mind, I'm seeking the (arduino) code to implement such a function: doing the following
1. on error (some faulty condition), disconnect (i.e., press the disconnect button)
2. re-connect (i.e., press the connect button).
in order to restart the sketch anew.
Am I missing anything obvious?
Are there such commands in Arduino (like restart, connect, disconnect)?
Also, some times the communication with the serial port is lost, and everything hangs out in a locked state; the only ways I found to recover communication is to either
a. physically disconnect and reconnect the serial communication cable, or
b. do the same using Windows Device Manager to Disable and next Enable the COMM port to which the arduino is connected.
Since both actions require manual intervention, I'd like to use a function in the Arduino code to do that automatically and remotely.
I'll appreciate any input on either (or both) matter(s).
Thanks,
Claude
I noticed that with the last MLP version, upon connecting (in any window, e.g., Time Plot, Monitor, Interface Panel or Connection Manager) after disconnecting the serial communication, the arduino sketch restarts from scratch as if it has just been loaded.
This somewhat confusing feature can nevertheless be useful as an error handling tool.
With this in mind, I'm seeking the (arduino) code to implement such a function: doing the following
1. on error (some faulty condition), disconnect (i.e., press the disconnect button)
2. re-connect (i.e., press the connect button).
in order to restart the sketch anew.
Am I missing anything obvious?
Are there such commands in Arduino (like restart, connect, disconnect)?
Also, some times the communication with the serial port is lost, and everything hangs out in a locked state; the only ways I found to recover communication is to either
a. physically disconnect and reconnect the serial communication cable, or
b. do the same using Windows Device Manager to Disable and next Enable the COMM port to which the arduino is connected.
Since both actions require manual intervention, I'd like to use a function in the Arduino code to do that automatically and remotely.
I'll appreciate any input on either (or both) matter(s).
Thanks,
Claude