From 7df511557f1e750bac4b45847f65e1e51aabdf54 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 20 Feb 2017 14:30:04 +0100 Subject: [PATCH] better serial integration, moved things outside --- CleanSerial | 2 +- Makefile | 3 ++- client/main.c | 3 --- install_clean.sh | 2 +- miTask.icl | 28 +++++++++++++--------------- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/CleanSerial b/CleanSerial index 2d370b4..8a5d422 160000 --- a/CleanSerial +++ b/CleanSerial @@ -1 +1 @@ -Subproject commit 2d370b44abe6ca0472a87201e98ed8b6f8d84b9a +Subproject commit 8a5d42279e8067d9dee26d5fae466deea27c6805 diff --git a/Makefile b/Makefile index 04e4d8c..e0d65c9 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ CLMLIBS:=\ BINARIES:= miTask mTaskExamples mTaskInterpret all: CleanSerial/Clean\ System\ Files/TTY.o $(BINARIES) client/mTaskSymbols.h - #find $(CLEAN_HOME)/lib -path '*/WebPublic/*' -execdir cp -nR {} "$$PWD"/miTask-www/ \; + mkdir -p miTask-www + find $(CLEAN_HOME)/lib -path '*/WebPublic/*' -not -path '*/CodeMirror/*' -execdir cp -nR {} "$$PWD"/miTask-www/ \; CleanSerial/Clean\ System\ Files/TTY.o: make -C CleanSerial diff --git a/client/main.c b/client/main.c index dc43de2..f3dd06a 100644 --- a/client/main.c +++ b/client/main.c @@ -55,9 +55,6 @@ void read_message(void) default: debug("Unknown message: %X", c); } - } else { - delay(1000); - printf("no input...\n"); } } diff --git a/install_clean.sh b/install_clean.sh index 63bcb5e..569cc65 100755 --- a/install_clean.sh +++ b/install_clean.sh @@ -12,6 +12,6 @@ fi rm -fr "$TARGET" mkdir -p "$TARGET" curl -sSL ftp://ftp.cs.ru.nl/pub/Clean/builds/linux-x64/clean-bundle-complete-linux-x64-latest.tgz \ - | gunzip | tar --strip-components=1 --extract --directory="$TARGET" + | tar --gunzip --strip-components=1 --extract --directory="$TARGET" echo "export CLEAN_HOME=$TARGET; export PATH=$TARGET/bin:\$PATH;" diff --git a/miTask.icl b/miTask.icl index 24444d9..5a87999 100644 --- a/miTask.icl +++ b/miTask.icl @@ -45,7 +45,7 @@ memoryShare :: String a -> Shared a | iTask a memoryShare s d = sdsFocus s $ memoryStore "" $ Just d deviceStore :: Shared [MTaskDevice] -deviceStore = memoryShare "mTaskDevices" [] +deviceStore = sharedStore "mTaskDevices" [] sdsStore :: Shared [MTaskShare] sdsStore = memoryShare "mTaskShares" [] @@ -54,10 +54,10 @@ bcStateStore :: Shared BCState bcStateStore = memoryShare "mTaskBCState" zero mTaskTaskStore :: Shared [String] -mTaskTaskStore = memoryShare "mTaskTasks" ["ledder", "ledon", "ledoff"] +mTaskTaskStore = memoryShare "mTaskTasks" ["count", "ledon", "ledoff"] mTaskMap :: Map String (Main (ByteCode () Stmt)) -mTaskMap = 'DM'.fromList [("ledder", bc), ("ledon", bc2 LED1), ("ledoff", bc3 LED3)] +mTaskMap = 'DM'.fromList [("count", bc), ("ledon", bc2 LED1), ("ledoff", bc3 LED3)] bc :: Main (ByteCode () Stmt) bc = sds \x=1 In sds \pinnetje=1 In {main = @@ -83,13 +83,13 @@ bc2 d = {main = ledOn d} bc3 :: UserLED -> Main (ByteCode () Stmt) bc3 d = {main = ledOff d} -:: MTaskDeviceStatus = {connected :: Bool, name :: String, tasks :: [(String, Int)]} +:: MTaskDeviceStatus = {connected :: Bool, name :: String, tasks :: [String]} derive class iTask MTaskDeviceStatus, MTaskDevice, MTaskShare, BCState mTaskManager :: Task () mTaskManager = anyTask [ viewmTasks @! () - , viewShares + , whileUnchanged sdsStore viewShares , whileUnchanged deviceStore viewDevices ] <<@ ApplyLayout layout where @@ -99,12 +99,12 @@ mTaskManager = anyTask ] viewmTasks = listmTasks - >&^ \sh->whileUnchanged sh $ \mi->case mi of + >&^ \sh->whileUnchanged sh $ \mi->forever (case mi of Nothing = viewInformation "No task selected" [] () Just mTaskTask = get deviceStore >>= \devices->case devices of [] = viewInformation "No devices yet" [] () - ds = sendmTask mTaskTask ds @! () + ds = sendmTask mTaskTask ds @! ()) where listmTasks :: Task String listmTasks = enterChoiceWithShared "Available mTasks" [ChooseFromList id] mTaskTaskStore @@ -142,8 +142,8 @@ mTaskManager = anyTask channels :: MTaskDevice -> Shared Channels channels d = memoryShare (fromJust d.deviceConnected) ([], [], False) - viewShares :: Task () - viewShares = whileUnchanged sdsStore $ anyTask o map viewer + viewShares :: [MTaskShare] -> Task () + viewShares st = anyTask $ map viewer st where viewer :: MTaskShare -> Task () viewer m = viewSharedInformation "" [] (getSDSStore m) @@ -180,9 +180,8 @@ mTaskManager = anyTask Just ty = case ty of TCPDevice = (enterInformation "Name" [] -&&- enterInformation "Hostname" [] -&&- enterInformation "Port" []) >>= \(name, (host, port))->cont name (syncNetworkChannel host port) - SerialDevice = accWorld getTTYDevices - >>= \dl->(enterInformation "Name" [] -&&- enterChoice "Device" [] dl -&&- updateInformation "Settings" [] zero) - >>= \(name, (dev, set))->cont name (syncSerialChannel dev set encode decode) + SerialDevice = (enterInformation "Name" [] -&&- enterTTYSettings) + >>= \(name, set)->cont name (syncSerialChannel set encode decode) where cont :: String ((Shared Channels) -> Task ()) -> Task () cont name synfun = get randomInt @@ -205,14 +204,13 @@ mTaskManager = anyTask MTSDSDelAck i = traceValue (toString m) @! () MTPub i val = getSDSRecord i >>= set (toInt val.[0]*256 + toInt val.[1]) o getSDSStore @! () MTMessage val = traceValue (toString m) @! () - MTEmpty = traceValue (toString m) @! () + MTEmpty = treturn () ) >>| process ms - deviceviewer :: [MTaskDevice] -> [MTaskDeviceStatus] deviceviewer ds = [{MTaskDeviceStatus | name = d.deviceName, connected = if (isNothing d.deviceConnected) False True, - tasks = d.deviceTasks}\\d<-ds] + tasks = [s +++ toString i\\(s, i)<-d.deviceTasks]}\\d<-ds] mapPar :: (a -> Task a) [a] -> Task () mapPar f l = foldr1 (\x y->f x ||- y) l <<@ ArrangeWithTabs @! () -- 2.20.1