Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mart Lubbers
CleanSerial
Commits
e2cf9a82
Commit
e2cf9a82
authored
Sep 23, 2016
by
Mart Lubbers
Browse files
stability fixes
parent
6b74b1d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
e2cf9a82
TTY
:
TTY.prj TTY.icl TTY.dcl Clean
\
System
\
Files/tty.o
c
p
m
make
c
l
m
-desc
-exl
-tst
-ns
-nt
TTY
-o
TTY
Clean\ System\ Files/tty.o
:
tty.c
gcc
-g
-c
$<
-o
"
$@
"
...
...
TTY.dcl
View file @
e2cf9a82
definition
module
TTY
from
Data
.
Maybe
import
::
Maybe
from
StdFile
import
class
FileSystem
from
StdClass
import
class
zero
...
...
TTY.icl
View file @
e2cf9a82
implementation
module
TTY
import
Data
.
Maybe
import
StdFunc
import
StdFile
...
...
@@ -79,8 +78,8 @@ Start :: *World -> (!String, *World)
Start
w
#!
(
ok
,
tty
,
w
)
=
TTYopen
"/dev/ttyUSB0"
zero
w
|
not
ok
=
TTYerror
w
#!
tty
=
TTYwrite
tty
"echo123
\n
"
#!
(
c
,
tty
)
=
TTYreadline
tty
#!
tty
=
TTYwrite
tty
"Hello World"
#!
(
ok
,
w
)
=
TTYclose
tty
w
|
not
ok
=
TTYerror
w
#!
(
s
,
w
)
=
TTYerror
w
...
...
tty.c
View file @
e2cf9a82
...
...
@@ -68,12 +68,7 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
tcsetattr
(
fd
,
TCSANOW
,
&
tio
);
*
f
=
fdopen
(
fd
,
"r+"
);
if
(
*
f
==
NULL
){
printf
(
"Couldn't open
\n
"
);
fflush
(
stdout
);
}
else
{
printf
(
"Succesfully opened
\n
"
);
fflush
(
stdout
);
if
(
*
f
!=
NULL
){
setbuf
(
*
f
,
NULL
);
*
status
=
1
;
}
...
...
@@ -121,13 +116,10 @@ void ttyreadline(FILE *fd, CleanString *result, FILE **fdo)
free
(
buf
);
}
int
ttywrite
(
FILE
*
fd
,
CleanString
s
,
FILE
**
fdo
)
FILE
*
ttywrite
(
FILE
*
fd
,
CleanString
s
)
{
char
*
cs_s
=
cleanStringToCString
(
s
);
fwrite
(
s
,
1
,
strlen
(
cs_s
),
fd
);
free
(
cs_s
);
*
fdo
=
fd
;
fwrite
(
CleanStringCharacters
(
s
),
1
,
CleanStringLength
(
s
),
fd
);
return
fd
;
}
int
ttyclose
(
FILE
*
fd
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment