示例#1
0
文件: arduino.cpp 项目: azwing/indi
int Arduino::closePort()
{
    if (strcmp(serialPort, "indi") == 0) return 0; // do not close port that we did not open

    int rv = 0;
    rv |= flushPort();
    if (fd < 0)
    {
        LOGF_DEBUG("Connection to %s already closed", serialPort);
        rv |= -1;
    }
    else if (tcsetattr(fd, TCSAFLUSH, &oldterm) < 0)
    {
        LOGF_DEBUG("Arduino::closePort():tcsetattr():%s", strerror(errno));
        rv |= -2;
        if (close(fd) < 0)
        {
            LOGF_DEBUG("Arduino::closePort():close():%s", strerror(errno));
            rv |= -4;
        }
        else
        {
            fd = -1;
        }
    }
    return (rv);
}
示例#2
0
文件: iofuncs.c 项目: timburrow/ovj3
int ioctl_serial(int fd, int action, ...)
{
    switch (action) {
    case IO_FLUSH:
        return flushPort(fd);

    case IO_DRAIN:
       return drainPort(fd);

    default:
        break;
    }

    return 0;
}