Commit e5dd13df authored by Matheus Andrade's avatar Matheus Andrade

serialSyncChannel ticker is parameterized

Also, removed an unused shared, probably leftover from old code, from when addBackgroundTask was used
parent cc48e634
...@@ -17,4 +17,4 @@ derive class iTask TTYSettings ...@@ -17,4 +17,4 @@ derive class iTask TTYSettings
* @result Task that stops when the stop flag is set * @result Task that stops when the stop flag is set
* @throws TTYException * @throws TTYException
*/ */
syncSerialChannel :: TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b
...@@ -30,10 +30,10 @@ import iTasks.Internal.TaskEval ...@@ -30,10 +30,10 @@ import iTasks.Internal.TaskEval
derive class iTask TTYSettings, Parity, BaudRate, ByteSize derive class iTask TTYSettings, Parity, BaudRate, ByteSize
syncSerialChannel :: TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b
syncSerialChannel opts enc dec rw = withShared "" \sh->Task $ eval sh syncSerialChannel poll opts enc dec rw = Task eval
where where
eval sh event evalOpts tree=:(TCInit taskId ts) iworld eval event evalOpts tree=:(TCInit taskId ts) iworld
# (mtty, iworld=:{world,resources}) = getResource iworld # (mtty, iworld=:{world,resources}) = getResource iworld
= case mtty of = case mtty of
[] = case TTYopen opts iworld.world of [] = case TTYopen opts iworld.world of
...@@ -51,7 +51,7 @@ where ...@@ -51,7 +51,7 @@ where
, iworld) , iworld)
_ = (exc "This tty was already open", iworld) _ = (exc "This tty was already open", iworld)
eval _ _ _ tree=:(TCBasic taskId ts (DeferredJSONNode (JSONString acc)) _) iworld eval _ _ tree=:(TCBasic taskId ts (DeferredJSONNode (JSONString acc)) _) iworld
# (mtty, iworld) = getResource iworld # (mtty, iworld) = getResource iworld
= case mtty of = case mtty of
[] = (exc"TTY resource lost", iworld) [] = (exc"TTY resource lost", iworld)
...@@ -88,7 +88,7 @@ where ...@@ -88,7 +88,7 @@ where
(TCBasic taskId ts (DeferredJSONNode $ JSONString newacc) False) (TCBasic taskId ts (DeferredJSONNode $ JSONString newacc) False)
, iworld) , iworld)
eval _ event evalOpts tree=:(TCDestroy _) iworld=:{IWorld|resources,world} eval event evalOpts tree=:(TCDestroy _) iworld=:{IWorld|resources,world}
# (mtty, iworld) = getResource iworld # (mtty, iworld) = getResource iworld
= case mtty of = case mtty of
[] = (exc "This tty was already closed", iworld) [] = (exc "This tty was already closed", iworld)
...@@ -100,7 +100,7 @@ where ...@@ -100,7 +100,7 @@ where
= (DestroyedResult, iworld) = (DestroyedResult, iworld)
rep = ReplaceUI $ stringDisplay $ "Serial client " <+++ opts.devicePath rep = ReplaceUI $ stringDisplay $ "Serial client " <+++ opts.devicePath
ticker = sdsFocus {start=zero,interval=zero} iworldTimespec ticker = sdsFocus {start=zero,interval=poll} iworldTimespec
getResource = iworldResource (\t=:(TTYd p _)->(p == opts.devicePath, t)) getResource = iworldResource (\t=:(TTYd p _)->(p == opts.devicePath, t))
exc = ExceptionResult o exception exc = ExceptionResult o exception
......
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