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
ad5a279b
Commit
ad5a279b
authored
Feb 20, 2017
by
Mart Lubbers
Browse files
add devicepath to TTYSettings
parent
2d370b44
Changes
5
Hide whitespace changes
Inline
Side-by-side
TTY.dcl
View file @
ad5a279b
...
...
@@ -11,6 +11,7 @@ from StdClass import class zero
B115200
|
B230400
::
TTYSettings
=
{
devicePath
::
String
,
baudrate
::
BaudRate
,
bytesize
::
ByteSize
,
parity
::
Parity
,
...
...
@@ -22,7 +23,7 @@ instance zero TTYSettings
TTYclose
::
!*
TTY
!*
env
->
(!
Bool
,
!*
env
)
TTYerror
::
!*
env
->
(!
String
,
!*
env
)
TTYopen
::
!
String
!
TTYSettings
!*
env
->
(!
Bool
,!*
TTY
,!*
env
)
TTYopen
::
!
TTYSettings
!*
env
->
(!
Bool
,!*
TTY
,!*
env
)
TTYread
::
!*
TTY
->
(!
Int
,
!*
TTY
)
TTYreadline
::
!*
TTY
->
(!
String
,
!*
TTY
)
TTYavailable
::
!*
TTY
->
(!
Bool
,
!*
TTY
)
...
...
TTY.icl
View file @
ad5a279b
...
...
@@ -11,6 +11,7 @@ import code from "ctty."
instance
zero
TTYSettings
where
zero
=
{
TTYSettings
|
devicePath
=
"/dev/ttyACM0"
,
baudrate
=
B9600
,
bytesize
=
BytesizeEight
,
parity
=
ParityNone
,
...
...
@@ -33,9 +34,9 @@ instance toInt Parity where
ParityNone
=
0
;
ParityOdd
=
1
;
ParityEven
=
2
;
ParitySpace
=
3
;
ParityMark
=
4
TTYopen
::
!
String
!
TTYSettings
!*
env
->
(!
Bool
,
!*
TTY
,
!*
env
)
TTYopen
fn
ts
w
=
TTYopen2
fn
TTYopen
::
!
TTYSettings
!*
env
->
(!
Bool
,
!*
TTY
,
!*
env
)
TTYopen
ts
w
=
TTYopen2
ts
.
devicePath
(
toInt
ts
.
baudrate
)
(
toInt
ts
.
bytesize
)
(
toInt
ts
.
parity
)
...
...
iTasksTTY.dcl
View file @
ad5a279b
...
...
@@ -7,4 +7,4 @@ derive class iTask TTYSettings
getTTYDevices
::
!*
env
->
*(![
String
],
!*
env
)
syncSerialChannel
::
String
TTYSettings
(
b
->
String
)
(
String
->
a
)
(
Shared
([
a
],[
b
],
Bool
))
->
Task
()
|
iTask
a
&
iTask
b
syncSerialChannel
::
TTYSettings
(
b
->
String
)
(
String
->
a
)
(
Shared
([
a
],[
b
],
Bool
))
->
Task
()
|
iTask
a
&
iTask
b
iTasksTTY.icl
View file @
ad5a279b
...
...
@@ -31,11 +31,11 @@ getTTYDevices w = case readDirectory "/dev" w of
isTTY
s
=
not
(
isEmpty
(
filter
(
flip
startsWith
s
)
prefixes
))
prefixes
=
[
"ttyS"
,
"ttyACM"
,
"ttyUSB"
,
"tty.usbserial"
]
syncSerialChannel
::
String
TTYSettings
(
b
->
String
)
(
String
->
a
)
(
Shared
([
a
],[
b
],
Bool
))
->
Task
()
|
iTask
a
&
iTask
b
syncSerialChannel
dev
opts
enc
dec
rw
=
Task
eval
syncSerialChannel
::
TTYSettings
(
b
->
String
)
(
String
->
a
)
(
Shared
([
a
],[
b
],
Bool
))
->
Task
()
|
iTask
a
&
iTask
b
syncSerialChannel
opts
enc
dec
rw
=
Task
eval
where
eval
event
evalOpts
tree
=:(
TCInit
taskId
ts
)
iworld
=:{
IWorld
|
world
}
=
case
TTYopen
dev
opts
world
of
=
case
TTYopen
opts
world
of
(
False
,
_,
world
)
#
(
err
,
world
)
=
TTYerror
world
=
(
ExceptionResult
(
exception
err
),
{
iworld
&
world
=
world
})
...
...
test.icl
View file @
ad5a279b
...
...
@@ -14,7 +14,7 @@ TTYerrorclose f w
Start
::
*
World
->
*
World
Start
w
#
(
io
,
w
)
=
stdio
w
#
(
ok
,
tty
,
w
)
=
TTYopen
"/dev/ttyUSB0"
zero
w
#
(
ok
,
tty
,
w
)
=
TTYopen
{
zero
&
devicePath
=
"/dev/ttyUSB0"
}
w
|
not
ok
=
TTYerrorclose
io
w
#!
tty
=
TTYwrite
"echo123
\n
"
tty
#!
(
av
,
tty
)
=
TTYavailable
tty
...
...
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