Commit 53e4d72a authored by Mart Lubbers's avatar Mart Lubbers
Browse files

clean up again

parent 7c7da5c8
# CleanSerial # CleanSerial
Serial port library for [clean](http://clean.cs.ru.nl). Build with `make`. Only
tested on linux but could work on mac too.
...@@ -29,6 +29,6 @@ TTYreadc :: !*TTY -> (!Char, !*TTY) ...@@ -29,6 +29,6 @@ TTYreadc :: !*TTY -> (!Char, !*TTY)
TTYreadline :: !*TTY -> (!String, !*TTY) TTYreadline :: !*TTY -> (!String, !*TTY)
TTYwrite :: !*TTY !String -> !*TTY TTYwrite :: !*TTY !String -> *TTY
TTYerror :: !*env -> (!String, !*env) TTYerror :: !*env -> (!String, !*env)
...@@ -64,7 +64,7 @@ TTYreadline t = code { ...@@ -64,7 +64,7 @@ TTYreadline t = code {
ccall ttyreadline "I:VSI" ccall ttyreadline "I:VSI"
} }
TTYwrite :: !*TTY !String -> !*TTY TTYwrite :: !*TTY !String -> *TTY
TTYwrite s e = code { TTYwrite s e = code {
ccall ttywrite "IS:I" ccall ttywrite "IS:I"
} }
......
...@@ -98,12 +98,10 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity, ...@@ -98,12 +98,10 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
//Baudrate //Baudrate
cfsetispeed(&tio, baudrates[baudrate]); cfsetispeed(&tio, baudrates[baudrate]);
//Bytesize //Bytesize
tio.c_cflag |= CS5 | CS6 | CS7 | CS8; tio.c_cflag &= ~CS5 | ~CS6 | ~CS7 | ~CS8;
tio.c_cflag -= CS5 | CS6 | CS7 | CS8;
tio.c_cflag |= bytesizes[bytesize]; tio.c_cflag |= bytesizes[bytesize];
//Parity //Parity
tio.c_cflag |= PARENB | PARODD | CMSPAR; tio.c_cflag &= ~PARENB | ~PARODD | ~CMSPAR;
tio.c_cflag -= PARENB | PARODD | CMSPAR;
if(parity == 1) if(parity == 1)
tio.c_cflag |= PARENB | PARODD; tio.c_cflag |= PARENB | PARODD;
else if(parity == 2) else if(parity == 2)
...@@ -113,11 +111,15 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity, ...@@ -113,11 +111,15 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
else if(parity == 4) else if(parity == 4)
tio.c_cflag |= PARENB | CMSPAR; tio.c_cflag |= PARENB | CMSPAR;
//Stopbits //Stopbits
tio.c_cflag |= CSTOPB; if(stopbits != 0)
tio.c_cflag -= stopbits == 0 ? 0 : CSTOPB; tio.c_cflag |= CSTOPB;
else
tio.c_cflag &= ~CSTOPB;
//Xonoff //Xonoff
tio.c_cflag |= IXON; if(xonoff == 1)
tio.c_cflag -= xonoff == 1 ? 0 : IXON; tio.c_cflag |= IXON;
else
tio.c_cflag &= ~IXON;
//Set //Set
tcsetattr(fd, TCSANOW, &tio); tcsetattr(fd, TCSANOW, &tio);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment