Commit e2cf9a82 authored by Mart Lubbers's avatar Mart Lubbers
Browse files

stability fixes

parent 6b74b1d6
TTY: TTY.prj TTY.icl TTY.dcl Clean\ System\ Files/tty.o TTY: TTY.prj TTY.icl TTY.dcl Clean\ System\ Files/tty.o
cpm make clm -desc -exl -tst -ns -nt TTY -o TTY
Clean\ System\ Files/tty.o: tty.c Clean\ System\ Files/tty.o: tty.c
gcc -g -c $< -o "$@" gcc -g -c $< -o "$@"
......
definition module TTY definition module TTY
from Data.Maybe import :: Maybe
from StdFile import class FileSystem from StdFile import class FileSystem
from StdClass import class zero from StdClass import class zero
......
implementation module TTY implementation module TTY
import Data.Maybe
import StdFunc import StdFunc
import StdFile import StdFile
...@@ -79,8 +78,8 @@ Start :: *World -> (!String, *World) ...@@ -79,8 +78,8 @@ Start :: *World -> (!String, *World)
Start w Start w
#! (ok, tty, w) = TTYopen "/dev/ttyUSB0" zero w #! (ok, tty, w) = TTYopen "/dev/ttyUSB0" zero w
| not ok = TTYerror w | not ok = TTYerror w
#! tty = TTYwrite tty "echo123\n"
#! (c, tty) = TTYreadline tty #! (c, tty) = TTYreadline tty
#! tty = TTYwrite tty "Hello World"
#! (ok, w) = TTYclose tty w #! (ok, w) = TTYclose tty w
| not ok = TTYerror w | not ok = TTYerror w
#! (s, w) = TTYerror w #! (s, w) = TTYerror w
......
...@@ -68,12 +68,7 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity, ...@@ -68,12 +68,7 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
tcsetattr(fd, TCSANOW, &tio); tcsetattr(fd, TCSANOW, &tio);
*f = fdopen(fd, "r+"); *f = fdopen(fd, "r+");
if(*f == NULL){ if(*f != NULL){
printf("Couldn't open\n");
fflush(stdout);
} else {
printf("Succesfully opened\n");
fflush(stdout);
setbuf(*f, NULL); setbuf(*f, NULL);
*status = 1; *status = 1;
} }
...@@ -121,13 +116,10 @@ void ttyreadline(FILE *fd, CleanString *result, FILE **fdo) ...@@ -121,13 +116,10 @@ void ttyreadline(FILE *fd, CleanString *result, FILE **fdo)
free(buf); free(buf);
} }
int ttywrite(FILE *fd, CleanString s, FILE **fdo) FILE *ttywrite(FILE *fd, CleanString s)
{ {
char *cs_s = cleanStringToCString(s); fwrite(CleanStringCharacters(s), 1, CleanStringLength(s), fd);
fwrite(s, 1, strlen(cs_s), fd); return fd;
free(cs_s);
*fdo = fd;
} }
int ttyclose(FILE *fd) int ttyclose(FILE *fd)
......
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