From: Mart Lubbers Date: Sun, 19 Feb 2017 15:41:16 +0000 (+0100) Subject: improve install script, add debug to the linux client, update jenkins behaviour X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=58e526fc46f667943873621c9029d7e5dd7c158e;p=mTask.git improve install script, add debug to the linux client, update jenkins behaviour --- diff --git a/client/Makefile.linux b/client/Makefile.linux index 43548ac..a08c84d 100644 --- a/client/Makefile.linux +++ b/client/Makefile.linux @@ -1,4 +1,4 @@ -CFLAGS:=-g -Wall -Wextra # -DDEBUG +CFLAGS:=-g -Wall -Wextra -DDEBUG PROG:=main OBJS:=interpret.o sds.o task.o main.o interface.o diff --git a/client/interface_linux.c b/client/interface_linux.c index e6e2df0..acfd0b8 100644 --- a/client/interface_linux.c +++ b/client/interface_linux.c @@ -153,6 +153,7 @@ void setup(void) fflush(stdout); if((fd = accept(sock_fd, (struct sockaddr*)NULL, NULL)) == -1) pdie("accept"); + printf("Accepted incoming connection\n"); } void debug(char *fmt, ...) diff --git a/client/main.c b/client/main.c index 90f6e5f..dc43de2 100644 --- a/client/main.c +++ b/client/main.c @@ -55,6 +55,9 @@ void read_message(void) default: debug("Unknown message: %X", c); } + } else { + delay(1000); + printf("no input...\n"); } } @@ -104,10 +107,10 @@ int main(int argc, char *argv[]){ setup(); sds_init(); task_init(); - //debug("booting up"); + debug("booting up"); while(true){ //Check for newetasks -// debug("loop"); + write_byte('\n'); loop(); delay(50); } diff --git a/install_clean.sh b/install_clean.sh index e21a1c6..63bcb5e 100755 --- a/install_clean.sh +++ b/install_clean.sh @@ -7,7 +7,7 @@ then fi TARGET="$(realpath "$1")" if [ -d "$TARGET" ]; then - mv "$TARGET" "$TARGET.$(date +%F)" + mv "$TARGET" "$TARGET.$(date +%F)" || rm -fr "$TARGET" fi rm -fr "$TARGET" mkdir -p "$TARGET" diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 319ffb3..8c8e422 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -114,4 +114,4 @@ toSDSUpdate :: Int Int -> [MTaskMSGSend] toByteVal :: BC -> [Char] toReadableByteCode :: (ByteCode a b) -> (String, BCState) -toRealByteCode :: (ByteCode a b) -> (String, BCState) +toRealByteCode :: (ByteCode a b) BCState -> (String, BCState) diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index f0cddf9..4876e93 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -229,9 +229,9 @@ instance zero BCState where zero = {freshl=[1..], freshs=[1..], sdss=[]} -toRealByteCode :: (ByteCode a b) -> (String, BCState) -toRealByteCode x -# (bc, st) = runBC x zero +toRealByteCode :: (ByteCode a b) BCState -> (String, BCState) +toRealByteCode x s +# (bc, st) = runBC x s # (bc, gtmap) = computeGotos bc 1 = (concat $ map (toString o toByteVal) (map (implGotos gtmap) bc), st) @@ -265,7 +265,7 @@ toMessages interval (bytes, st=:{sdss}) = ([MTSds i (toString b)\\(i,b)<-sdss] + toSDSUpdate :: Int Int -> [MTaskMSGSend] toSDSUpdate i v = [MTUpd i (to16bit v)] -Start = toMessages 500 $ toRealByteCode (unMain bc) +Start = toMessages 500 $ toRealByteCode (unMain bc) zero where bc = sds \x=5 In sds \y=4 In diff --git a/miTask.icl b/miTask.icl index 738f8c2..1e62ea7 100644 --- a/miTask.icl +++ b/miTask.icl @@ -61,6 +61,9 @@ bcStateStore = memoryShare "mTaskBCState" zero mTaskTaskStore :: Shared [String] mTaskTaskStore = memoryShare "mTaskTasks" ["ledder", "ledon", "ledoff"] +mTaskMap :: Map String (Main (ByteCode () Stmt)) +mTaskMap = 'DM'.fromList [("ledder", bc), ("ledon", bc2 LED1), ("ledoff", bc3 LED3)] + bc :: Main (ByteCode () Stmt) bc = sds \x=1 In sds \pinnetje=1 In {main = IF (digitalRead D3) ( @@ -109,12 +112,37 @@ mTaskManager = anyTask listmTasks :: Task String listmTasks = enterChoiceWithShared "Available mTasks" [ChooseFromList id] mTaskTaskStore - sendmTask mTaskId ds = enterChoice "Choose Device" [ChooseFromDropdown (\t->t.deviceName)] ds <<@ Title mTaskId - >>* [OnAction (Action "Send") (withValue $ sendToDevice mTaskId)] - - sendToDevice mTask device = Just $ viewInformation "" [] device + sendmTask mTaskId ds = + (enterChoice "Choose Device" [ChooseFromDropdown \t->t.deviceName] ds + -&&- enterInformation "Timeout, 0 for one-shot" []) + >>* [OnAction (Action "Send") (withValue $ Just o sendToDevice mTaskId)] + + sendToDevice :: String (MTaskDevice, Int) -> Task () + sendToDevice mTask (device, timeout) = get bcStateStore + @ toMessages timeout o toRealByteCode (unMain $ fromJust ('DM'.get mTask mTaskMap)) + >>= \(msgs, st1)->set st1 bcStateStore + //@ map f + >>| upd (\(r,s,ss)->(r,s++msgs,ss)) (channels device) + @! () + where + f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) (dd d)) + dd [x,y] = toInt x*265 + toInt y + +// = (msgs, map f st.sdss) +// where +// upd (\(r,s,ss)->(r,s++[],ss)) (channels device) @! () +// # (msgs, st) = toMessages timeout (toRealByteCode (unMain bc)) +// = Just $ viewInformation "" [] device +// = (msgs, map f st.sdss) +// where +// f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) (dd d)) +// dd [x,y] = toInt x*265 + toInt y +// # +// = Just $ viewInformation "" [] device + channels :: MTaskDevice -> Shared Channels + channels d = memoryShare (fromJust d.deviceConnected) ([], [], False) layout = sequenceLayouts [ arrangeWithSideBar 0 LeftSide 260 True @@ -123,13 +151,14 @@ mTaskManager = anyTask viewShares :: Task () viewShares = forever $ - enterChoiceWithShared "Shares" [ChooseFromList sdsvw] sdsShare + enterChoiceWithShared "Shares" [ChooseFromList id] sdsStore >>* [OnValue $ withValue $ Just o updateShare] >>* [OnAction (Action "Back") (const $ Just $ treturn ())] where sdsvw (k, v) = concat ["SDS ", toString k, ": ", toString v] - updateShare (k, v) = (viewInformation "Key" [] k - ||- updateInformation "Value" [] v) + updateShare s = viewInformation "" [] () +// updateShare (k, v) = (viewInformation "Key" [] k +// ||- updateInformation "Value" [] v) viewDevices :: [MTaskDevice] -> Task () @@ -141,28 +170,23 @@ mTaskManager = anyTask viewDevice :: MTaskDevice -> Task () viewDevice d = (viewInformation "Device settings" [] d ||- (case d.deviceConnected of - Just s = viewSharedInformation "Channels" [] (channels d.deviceName) @! () + Just s = viewSharedInformation "Channels" [ViewAs dropEmpty] (channels d) @! () Nothing = viewInformation "No channels yet" [] "" @! () )) <<@ ArrangeHorizontal - - channels :: String -> Shared Channels - channels s = sdsFocus s $ memoryStore "" $ Just ([], [], False) - - sdsShare :: Shared [(Int, Int)] - sdsShare = sdsFocus "mTaskSDSs" $ memoryStore "" $ Just [(1, 1)] + where + dropEmpty (r,s,ss) = (filter ((=!=)MTEmpty) r,s,ss) addDevice :: (Shared [MTaskDevice]) -> Task () addDevice devices = enterInformation "Device type and name" [] - >>= \(name, ty)->get randomInt @ ((+++) name o toString) - >>= \realname->let ch = channels realname in case ty of + >>= \(name, ty)->get randomInt @ (\randint->{deviceConnected=Just (name +++ toString randint), deviceName=name, deviceTasks=[]}) + >>= \dev->let ch = channels dev in case ty of TCPDevice = enterInformation "Hostname and port" [] - >>= \(host, port)->cont realname name ||- syncNetworkChannel host port ch + >>= \(host, port)->cont dev ||- syncNetworkChannel host port ch SerialDevice = accWorld getDevices >>= \dl->(enterChoice "Device" [] dl -&&- updateInformation "Settings" [] zero) - >>= \(device, settings)->cont realname name ||- syncSerialChannel device settings ch + >>= \(device, settings)->cont dev ||- syncSerialChannel device settings ch where - cont rn nm = (upd (\l->[dev rn nm:l]) devices >>| addDevice devices) - dev rn nm = {deviceConnected=Just rn,deviceName=nm,deviceTasks=[]} + cont d = (upd (\l->[d:l]) devices >>| addDevice devices) getDevices :: !*World -> *(![String], !*World) getDevices w = case readDirectory "/dev" w of @@ -321,8 +345,9 @@ serialDeviceBackgroundTask rw iworld syncNetworkChannel :: String Int (Shared ([MTaskMSGRecv], [MTaskMSGSend], Bool)) -> Task () -syncNetworkChannel server port channel - = tcpconnect server port channel {ConnectionHandlers|onConnect=onConnect,whileConnected=whileConnected,onDisconnect=onDisconnect} @! () +syncNetworkChannel server port channel = catchAll + (tcpconnect server port channel {ConnectionHandlers|onConnect=onConnect,whileConnected=whileConnected,onDisconnect=onDisconnect} @! ()) + (\v->traceValue v @! ()) where onConnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool) onConnect _ (msgs,send,sendStopped) @@ -333,8 +358,9 @@ syncNetworkChannel server port channel = (Ok acc, Nothing, [], False) whileConnected (Just newData) acc (msgs,send,sendStopped) - | sendStopped = (Ok acc, Just (msgs ++ [decode newData],[],False), map encode send, False) - = (Ok acc, Just (msgs ++ [decode newData],[],False), [], False) + = (Ok acc, Just (msgs ++ [decode newData],[],False), map encode send, False) + //| sendStopped = (Ok acc, Just (msgs ++ [decode newData],[],False), map encode send, False) +// = (Ok acc, Just (msgs ++ [decode newData],[],False), [], False) onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool)) onDisconnect l (msgs,send,sendStopped) = (Ok l, Nothing)