Commit f19e7825 authored by Mart Lubbers's avatar Mart Lubbers

organize

parent 1e4560f3
...@@ -2,22 +2,44 @@ definition module TTY ...@@ -2,22 +2,44 @@ definition module TTY
from StdClass import class zero from StdClass import class zero
/**
* TTY handle
*/
:: *TTY (:== Int) :: *TTY (:== Int)
/**
* Possible byte sizes
*/
:: ByteSize = BytesizeFive | BytesizeSix | BytesizeSeven | BytesizeEight :: ByteSize = BytesizeFive | BytesizeSix | BytesizeSeven | BytesizeEight
/**
* Possible parity settings
*/
:: Parity = ParityNone | ParityOdd | ParityEven | ParitySpace | ParityMark :: Parity = ParityNone | ParityOdd | ParityEven | ParitySpace | ParityMark
/**
* Possible baudrates
*/
:: BaudRate = B0 | B50 | B75 | B110 | B134 | B150 | B200 | B300 | B600 | :: BaudRate = B0 | B50 | B75 | B110 | B134 | B150 | B200 | B300 | B600 |
B1200 | B1800 | B2400 | B4800 | B9600 | B19200 | B38400 | B57600 | B1200 | B1800 | B2400 | B4800 | B9600 | B19200 | B38400 | B57600 |
B115200 | B230400 B115200 | B230400
/**
* Serial device settings
*/
:: TTYSettings = { :: TTYSettings = {
devicePath :: String, devicePath :: String,
//* Path of the device, e.g. /dev/ttyACM0
baudrate :: BaudRate, baudrate :: BaudRate,
//* Baudrate
bytesize :: ByteSize, bytesize :: ByteSize,
//* Parity
parity :: Parity, parity :: Parity,
//* stop2bits
stop2bits :: Bool, stop2bits :: Bool,
//* xonxoff flow control
xonxoff :: Bool, 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 sleepTime :: Int
} }
...@@ -26,9 +48,9 @@ instance zero TTYSettings ...@@ -26,9 +48,9 @@ instance zero TTYSettings
/** /**
* Returns a list of tty devices. This list is not conclusive but just checks familiar names. * Returns a list of tty devices. This list is not conclusive but just checks familiar names.
* *
* @param The world * @param world
* @result The list of detected devices * @result list of detected devices
* @result The updated world * @result new world
*/ */
getTTYDevices :: !*World -> *(![String], !*World) getTTYDevices :: !*World -> *(![String], !*World)
......
implementation module TTY implementation module TTY
import StdFunc, StdBool import StdEnv
import StdList
import System.OS import System.OS
import Text import Text
import StdArray
import StdClass
import StdString
import StdChar
import Platform import Platform
import code from "ctty." import code from "ctty."
......
definition module iTasksTTY 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 from TTY import :: TTYSettings
import iTasks
derive class iTask TTYSettings derive class iTask TTYSettings
......
implementation module iTasksTTY implementation module iTasksTTY
import System.OS import StdEnv
import TTY
import StdList import Data.Func
from StdFunc import o, flip import Text
import StdMisc
import StdString
import Data.List
import qualified Data.Map as DM
import System.Directory
import iTasks 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.IWorld
import iTasks.Internal.TaskState
import iTasks.Internal.Task
import iTasks.Internal.SDS import iTasks.Internal.SDS
import iTasks.Internal.TaskServer
import iTasks.Internal.TaskEval import iTasks.Internal.TaskEval
import iTasks.Internal.TaskState
import TTY
:: *Resource | TTYd String *TTY :: *Resource | TTYd String *TTY
...@@ -76,7 +63,7 @@ where ...@@ -76,7 +63,7 @@ where
| isError merr = (exc (fromError merr), iworld) | isError merr = (exc (fromError merr), iworld)
# iworld = {iworld & resources=[TTYd dp tty:iworld.resources]} # iworld = {iworld & resources=[TTYd dp tty:iworld.resources]}
= case dec (acc +++ toString (fromOk merr)) of = 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) (Right msgs, newacc)
# (merr, iworld) = if (msgs =: [] && s =: []) # (merr, iworld) = if (msgs =: [] && s =: [])
(Ok (), iworld) (Ok (), iworld)
......
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