Home:ALL Converter>OS X serial port open with DTR low

OS X serial port open with DTR low

Ask Time:2013-07-12T02:52:14         Author:mbohn

Json Formatter

I've written serial port access code for Windows and OS X but on the latter I've yet to find a way to open the port with DTR low. (I'm trying to avoid reseting my Arduino.) Here is the simplest version of my C code that demonstrates the problem:

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 can 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() ? Could this be a function of the USB driver?

Author:mbohn,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/17601142/os-x-serial-port-open-with-dtr-low
yy