Skip to content
GitLab
Menu
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
e259a05e
Commit
e259a05e
authored
Jan 21, 2017
by
Mart Lubbers
Browse files
fix soome issues
parent
553b6622
Changes
5
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
e259a05e
test
:
test.icl TTY.icl TTY.dcl Clean
\
System
\
Files/ctty.o
clm
$(
basename
$<
)
-o
$@
clm
-dynamics
-l
-no-pie
-I
/opt/clean/lib/Dynamics
$(
basename
$<
)
-o
$@
Clean\ System\ Files/ctty.o
:
tty.c
gcc
-c
$<
-o
"
$@
"
gcc
-5
-c
$<
-o
"
$@
"
clean
:
$(RM)
-r
Clean
\
System
\
Files/
*
test
TTY.dcl
View file @
e259a05e
...
...
@@ -25,4 +25,4 @@ TTYerror :: !*env -> (!String, !*env)
TTYopen
::
!
String
!
TTYSettings
!*
env
->
(!
Bool
,!*
TTY
,!*
env
)
TTYreadline
::
!*
TTY
->
(!
String
,
!*
TTY
)
TTYavailable
::
!*
TTY
->
(!
Bool
,
!*
TTY
)
TTYwrite
::
!
*
TTY
!
String
->
*
TTY
TTYwrite
::
!
String
!*
TTY
->
*
TTY
TTY.icl
View file @
e259a05e
...
...
@@ -55,9 +55,9 @@ TTYreadline _ = code {
ccall
ttyreadline
"I:VSI"
}
TTYwrite
::
!
*
TTY
!
String
->
*
TTY
TTYwrite
::
!
String
!*
TTY
->
*
TTY
TTYwrite
_
_
=
code {
ccall
ttywrite
"
I
S:I"
ccall
ttywrite
"S
I
:I"
}
TTYavailable
::
!*
TTY
->
(!
Bool
,
!*
TTY
)
...
...
test.icl
View file @
e259a05e
...
...
@@ -16,7 +16,7 @@ Start w
#
(
io
,
w
)
=
stdio
w
#
(
ok
,
tty
,
w
)
=
TTYopen
"/dev/ttyUSB0"
zero
w
|
not
ok
=
TTYerrorclose
io
w
#!
tty
=
TTYwrite
tty
"echo123
\n
"
#!
tty
=
TTYwrite
"echo123
\n
"
tty
#!
(
av
,
tty
)
=
TTYavailable
tty
#
io
=
io
<<<
(
"Bytes available: "
+++
toString
av
+++
"
\n
"
)
#!
(
l
,
tty
)
=
TTYreadline
tty
...
...
tty.c
View file @
e259a05e
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
...
...
@@ -203,7 +204,7 @@ void ttyreadline(int fd, CleanString *result, int *fdo)
void
ttyavailable
(
int
fd
,
int
*
r
,
int
*
fdo
)
{
debug
(
"ttyavailable"
);
//
debug("ttyavailable");
fd_set
fds
;
struct
timeval
tv
;
tv
.
tv_sec
=
0
;
...
...
@@ -216,10 +217,10 @@ void ttyavailable(int fd, int *r, int *fdo)
if
(
*
r
==
-
1
)
die
(
"select"
);
*
fdo
=
fd
;
debug
(
"ttyavailable-done"
);
//
debug("ttyavailable-done");
}
int
ttywrite
(
int
fd
,
CleanString
s
)
int
ttywrite
(
CleanString
s
,
int
fd
)
{
debug
(
"ttywrite"
);
write
(
fd
,
CleanStringCharacters
(
s
),
CleanStringLength
(
s
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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