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); }
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; }