public void Open() { // open serial port int fd = Libc.open(portName, Libc.OpenFlags.O_RDWR | Libc.OpenFlags.O_NONBLOCK); if (fd == -1) { throw new Exception($"failed to open port ({portName})"); } // set baud rate byte[] termiosData = new byte[256]; Libc.tcgetattr(fd, termiosData); Libc.cfsetspeed(termiosData, baudRate); Libc.tcsetattr(fd, 0, termiosData); // start reading Task.Run((Action)StartReading, CancellationToken); this.fd = fd; }
private void SetTermios(Termios terminos) { byte[] termiosData = TermiosHelpers.getBytes(terminos); Libc.tcsetattr(_FileDescriptor.Value, 0, termiosData); }