From 3698f150b0c5e5ebed23b0885ced2711ef16d9f5 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sat, 28 Jan 2017 13:53:02 +0100 Subject: [PATCH] update now working --- CleanSerial | 2 +- int/interface.c | 14 +++++++------- int/interface.h | 2 +- int/main.c | 8 +++++--- int/task.c | 4 ++++ mTaskInterpret.dcl | 1 + mTaskInterpret.icl | 2 ++ miTask.icl | 15 ++++++++------- 8 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CleanSerial b/CleanSerial index 71526f6..3afa2bb 160000 --- a/CleanSerial +++ b/CleanSerial @@ -1 +1 @@ -Subproject commit 71526f6a1cc5b289d3963c6396a600bba1f5c416 +Subproject commit 3afa2bb48da41a8467b7197e5eebabbec3c6acfe diff --git a/int/interface.c b/int/interface.c index 0916ee5..6809110 100644 --- a/int/interface.c +++ b/int/interface.c @@ -16,7 +16,7 @@ bool input_available(void) uint8_t read_byte(void) { - return sdGet(&SD3); + return (uint8_t)sdGet(&SD3); } void write_byte(uint8_t b) @@ -75,12 +75,12 @@ void setup(void) void debug(char *fmt, ...) { - //unsigned int i; - //write_byte('m'); - //for(i = 0; i Int diff --git a/miTask.icl b/miTask.icl index 2634ce8..92fbff2 100644 --- a/miTask.icl +++ b/miTask.icl @@ -54,14 +54,15 @@ bc = sds \x=1 In sds \pinnetje=1 In {main = ) )} -deviceSelector :: (Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task () -deviceSelector ch = enterInformation "Type" [] +withDevice :: ((Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task a) -> Task a | iTask a +withDevice t = withShared ([], [], False) \ch-> + enterInformation "Type" [] >>= \ty->case ty of TCP = (enterInformation "Host" [] -&&- enterInformation "Port" []) - >>= \(port,host)->syncNetworkChannel host port ch + >>= \(port,host)->t ch -|| syncNetworkChannel host port ch Serial = accWorld getDevices >>= \dl->(enterChoice "Device" [] dl -&&- updateInformation "Settings" [] zero) - >>= \(dev,set)->syncSerialChannel dev set ch + >>= \(dev,set)->t ch -|| syncSerialChannel dev set ch where getDevices :: !*World -> *(![String], !*World) getDevices w = case readDirectory "/dev" w of @@ -73,8 +74,8 @@ deviceSelector ch = enterInformation "Type" [] mTaskTask :: Task () mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in - withShared ([], msgs, False) (\ch-> - deviceSelector ch + withDevice (\ch-> + sendMsg msgs ch ||- processMessages ch messageShare sdsShares ||- viewSharedInformation "channels" [ViewWith lens] ch ||- viewSharedInformation "messages" [] messageShare @@ -103,10 +104,10 @@ mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in updateSDSs :: [(Int, Shared Int)] (Shared [String]) MTaskMSGRecv -> Task () updateSDSs _ m (MTMessage s) = upd (\l->take 20 [s:l]) m @! () - updateSDSs _ _ MTEmpty = return () updateSDSs [(id, sh):xs] m n=:(MTPub i d) | id == i = set ((toInt d.[0])*265 + toInt d.[1]) sh @! () = updateSDSs xs m n + updateSDSs _ _ _ = return () lens :: ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> ([String], [String]) lens (r,s,_) = (map toString r, map toString s) -- 2.20.1