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
f19e7825
Commit
f19e7825
authored
Sep 26, 2018
by
Mart Lubbers
Browse files
organize
parent
1e4560f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
TTY.dcl
View file @
f19e7825
...
...
@@ -2,22 +2,44 @@ definition module TTY
from
StdClass
import
class
zero
/**
* TTY handle
*/
::
*
TTY
(:==
Int
)
/**
* Possible byte sizes
*/
::
ByteSize
=
BytesizeFive
|
BytesizeSix
|
BytesizeSeven
|
BytesizeEight
/**
* Possible parity settings
*/
::
Parity
=
ParityNone
|
ParityOdd
|
ParityEven
|
ParitySpace
|
ParityMark
/**
* Possible baudrates
*/
::
BaudRate
=
B0
|
B50
|
B75
|
B110
|
B134
|
B150
|
B200
|
B300
|
B600
|
B1200
|
B1800
|
B2400
|
B4800
|
B9600
|
B19200
|
B38400
|
B57600
|
B115200
|
B230400
/**
* Serial device settings
*/
::
TTYSettings
=
{
devicePath
::
String
,
//* Path of the device, e.g. /dev/ttyACM0
baudrate
::
BaudRate
,
//* Baudrate
bytesize
::
ByteSize
,
//* Parity
parity
::
Parity
,
//* stop2bits
stop2bits
::
Bool
,
//* xonxoff flow control
xonxoff
::
Bool
,
//Set this to 2 if you want to connect to a borked arduino
//
* Time in seconds to wait after opening the devices.
Set this to 2 if you want to connect to a borked arduino
sleepTime
::
Int
}
...
...
@@ -26,9 +48,9 @@ instance zero TTYSettings
/**
* Returns a list of tty devices. This list is not conclusive but just checks familiar names.
*
* @param
The
world
* @result
The
list of detected devices
* @result
The updated
world
* @param world
* @result list of detected devices
* @result
new
world
*/
getTTYDevices
::
!*
World
->
*(![
String
],
!*
World
)
...
...
TTY.icl
View file @
f19e7825
implementation
module
TTY
import
Std
Func
,
StdBool
import
StdList
import
Std
Env
import
System
.
OS
import
Text
import
StdArray
import
StdClass
import
StdString
import
StdChar
import
Platform
import
code
from
"ctty."
...
...
iTasksTTY.dcl
View file @
f19e7825
definition
module
iTasksTTY
from
iTasks
.
Internal
.
Generic
.
Visualization
import
generic
gText
,
::
TextFormat
from
iTasks
.
SDS
.
Definition
import
::
SDS
,
::
Shared
,
::
RWShared
from
iTasks
.
UI
.
Editor
.
Generic
import
generic
gEditor
,
::
Editor
from
iTasks
.
WF
.
Definition
import
::
Task
from
iTasks
.
WF
.
Definition
import
class
iTask
from
Data
.
GenDefault
import
generic
gDefault
from
Data
.
GenEq
import
generic
gEq
from
Data
.
Maybe
import
::
Maybe
from
Data
.
Either
import
::
Either
from
Text
.
GenJSON
import
generic
JSONEncode
,
generic
JSONDecode
,
::
JSONNode
from
System
.
Time
import
::
Timespec
from
TTY
import
::
TTYSettings
import
iTasks
derive
class
iTask
TTYSettings
...
...
iTasksTTY.icl
View file @
f19e7825
implementation
module
iTasksTTY
import
System
.
OS
import
TTY
import
StdEnv
import
StdList
from
StdFunc
import
o
,
flip
import
StdMisc
import
StdString
import
Data
.
List
import
qualified
Data
.
Map
as
DM
import
Data
.
Func
import
Text
import
System
.
Directory
import
iTasks
import
Data
.
Tuple
import
Control
.
Applicative
from
Data
.
Func
import
$
from
Text
import
class
Text
(
startsWith
),
instance
Text
String
import
iTasks
.
UI
.
Definition
import
iTasks
.
Internal
.
IWorld
import
iTasks
.
Internal
.
TaskState
import
iTasks
.
Internal
.
Task
import
iTasks
.
Internal
.
SDS
import
iTasks
.
Internal
.
TaskServer
import
iTasks
.
Internal
.
TaskEval
import
iTasks
.
Internal
.
TaskState
import
TTY
::
*
Resource
|
TTYd
String
*
TTY
...
...
@@ -76,7 +63,7 @@ where
|
isError
merr
=
(
exc
(
fromError
merr
),
iworld
)
#
iworld
=
{
iworld
&
resources
=[
TTYd
dp
tty
:
iworld
.
resources
]}
=
case
dec
(
acc
+++
toString
(
fromOk
merr
))
of
(
Left
err
,
newacc
)
=
(
exc
"Error while parsing
"
,
iworld
)
(
Left
err
,
newacc
)
=
(
exc
(
"Error while parsing
: "
+++
join
" "
[
toString
(
toInt
c
)\\
c
<-:
acc
+
toString
(
fromOk
merr
)])
,
iworld
)
(
Right
msgs
,
newacc
)
#
(
merr
,
iworld
)
=
if
(
msgs
=:
[]
&&
s
=:
[])
(
Ok
(),
iworld
)
...
...
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