[moserial] remove redundant serial setup code, and rely mostly on cfmakeraw to set mode
- From: Michael J. Chudobiak <mjc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [moserial] remove redundant serial setup code, and rely mostly on cfmakeraw to set mode
- Date: Sat, 16 Jan 2021 19:16:45 +0000 (UTC)
commit f72c83db8c9394b5291655bb8c2381c3cb3743be
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Sat Jan 16 14:14:51 2021 -0500
remove redundant serial setup code, and rely mostly on cfmakeraw to set mode
src/SerialConnection.vala | 31 ++++---------------------------
1 file changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/src/SerialConnection.vala b/src/SerialConnection.vala
index 2e29e84..0fa662f 100644
--- a/src/SerialConnection.vala
+++ b/src/SerialConnection.vala
@@ -33,7 +33,6 @@ public class moserial.SerialConnection : GLib.Object
public string echoCompare = "";
private Posix.termios newtio;
- private Posix.termios restoretio;
private int m_fd = -1;
private GLib.IOChannel IOChannelFd;
public signal void newData (uchar[] data, int size);
@@ -72,7 +71,6 @@ public class moserial.SerialConnection : GLib.Object
}
Posix.tcflush (m_fd, Posix.TCIOFLUSH);
- tcgetattr (m_fd, out restoretio);
applySettings (settings);
tcsetattr (m_fd, Posix.TCSANOW, newtio);
@@ -219,6 +217,10 @@ public class moserial.SerialConnection : GLib.Object
Posix.cfsetospeed (ref newtio, baudRate);
Posix.cfsetispeed (ref newtio, baudRate);
+ Posix.cfmakeraw(ref newtio);
+ newtio.c_cc[Posix.VTIME]=0;
+ newtio.c_cc[Posix.VMIN]=1;
+
// DataBits
int dataBits;
dataBits = settings.dataBits;
@@ -250,43 +252,18 @@ public class moserial.SerialConnection : GLib.Object
else if (settings.parity == Settings.Parity.ODD)
newtio.c_cflag |= (Posix.PARENB | Posix.PARODD);
- newtio.c_cflag &= ~Linux.Termios.CRTSCTS;
-
-
// Stop Bits
if (settings.stopBits == 2)
newtio.c_cflag |= Posix.CSTOPB;
else
newtio.c_cflag &= ~Posix.CSTOPB;
- // Input Settings
- newtio.c_iflag = Posix.IGNBRK;
-
// Handshake
if (settings.handshake == Settings.Handshake.SOFTWARE || settings.handshake ==
Settings.Handshake.BOTH)
newtio.c_iflag |= Posix.IXON | Posix.IXOFF;
else
newtio.c_iflag &= ~(Posix.IXON | Posix.IXOFF | Posix.IXANY);
- newtio.c_lflag = 0;
- newtio.c_oflag = 0;
-
- newtio.c_cc[Posix.VTIME] = 1;
- newtio.c_cc[Posix.VMIN] = 1;
-
-
- // Some other port settings from minicom.
-
- // newtio.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC | IXANY | IXON | IXOFF | INPCK |
ISTRIP);
- // newtio.c_iflag &= ~(Posix.IGNBRK | Posix.IGNCR | Posix.InputMode.INLCR | Posix.InputMode.ICRNL |
Posix.IXANY | Posix.IXON | Posix.IXOFF | Posix.INPCK | Posix.ISTRIP);
- // newtio.c_iflag |= (Posix.BRKINT | Posix.IGNPAR);
- // newtio.c_oflag &= ~Posix.OPOST;
- // newtio.c_lflag &= ~(XCASE|ECHONL|NOFLSH);
- newtio.c_lflag &= ~(Posix.ECHONL | Posix.NOFLSH);
- // newtio.c_lflag &= ~(Posix.ICANON | Posix.ISIG | Posix.ECHO);
- // newtio.c_cflag |= CREAD;
- // newtio.c_cc[VTIME] = 5;
-
if (settings.handshake == Settings.Handshake.HARDWARE || settings.handshake ==
Settings.Handshake.BOTH)
newtio.c_cflag |= Linux.Termios.CRTSCTS;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]