I've written serial monitor code for Windows and OS X but on the latter I've yet to find a way to open the port with DTR low to avoid reseting the Arduino. Here is the simplest version of my C code:
const char *pathname = "/dev/tty.usbmodem411";
….
int main()
{
int fd;
int status;
printf(" STARTING SERIAL PORT PROGRAM \n");
fd = open(pathname, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd != -1) printf(" port successfully opened, fd = %d\n",fd) ;
else
{
printf(" could not open port\n");
return;
}
printf("closing port and quitting app\n");
if (fd !=-1) close(fd);
return 0;
}
I haven't found any other open() flags that help. I have successfully set DTR low after opening the port via ioctl() but that doesn't help since the Arduino is resetting on open().
Does anyone know how to keep DTR low during open() ?