bool TTYPort::Open(const TCHAR *path, unsigned _baud_rate) { if (IsAndroid()) { /* attempt to give the XCSoar process permissions to access the USB serial adapter; this is mostly relevant to the Nook */ TCHAR command[MAX_PATH]; StringFormat(command, MAX_PATH, "su -c 'chmod 666 %s'", path); system(command); } if (!tty.OpenNonBlocking(path)) { LogErrno(_T("Failed to open port '%s'"), path); return false; } baud_rate = _baud_rate; if (!SetBaudrate(baud_rate)) return false; valid.store(true, std::memory_order_relaxed); io_thread->LockAdd(tty.ToFileDescriptor(), Poll::READ, *this); StateChanged(); return true; }
bool TTYPort::Open(const TCHAR *path, unsigned _baud_rate) { fd = open(path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { LogErrno(_T("Failed to open port '%s'"), path); return false; } baud_rate = _baud_rate; if (!SetBaudrate(baud_rate)) return false; valid.Set(); return true; }