Hey all,
I have a bit of C code that opens a serial port with the correct settings and everything, does some communication with firmata and then optionally close the port. Below I'll paste my `arduino_close()` function. I get the desired behavior on my UNO and my 3 Mega rev2's; that is, when the port is closed, DTR is raised and the board resets.
However, on the Mega rev3, with the exact same host code and the exact same sketch that works with my other arduinos above, on close, the board does not reset and the TX light is solid. I've been researching linux/windows serial and modem programming extensively for the last few months and I think I may be missing something that the rev3 expects. I am just not sure. My code though has been working for about 1.3 years without an issue on multiple arduinos without issues/this problem; it looks like it just effects Mega 2560 rev3.
Here is my close function:
void arduino_close(){
tcflush(fd, TCIFLUSH);
tcdrain(fd);
usleep(1000000);
tcsetattr(fd, TCSANOW, &settings_orig);
close(fd);
fd = 0;
}
Like I said above, this works perfectly on my UNOs and older Mega 2560s ; the port gets closed and the original TTY settings restored and the board gets reset.
Any help would be appreciated. Thanks.