From: Mart Lubbers Date: Fri, 17 Mar 2017 15:16:51 +0000 (+0100) Subject: fix device deletion X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=1827e72942a355fc90dcb4e0b93f68c98dc6eea5;p=mTask.git fix device deletion --- diff --git a/CleanSerial b/CleanSerial index ef64133..51fb89d 160000 --- a/CleanSerial +++ b/CleanSerial @@ -1 +1 @@ -Subproject commit ef6413393c66231637cc89c252c28e866a46f14b +Subproject commit 51fb89d38cf4fc3231f32da3fc8bc174eb05a1ab diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index ef94a06..537a3b9 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -92,7 +92,7 @@ viewDevice pf d = forever $ traceValue "viewDevice" >>| anyTask deleteDevice :: MTaskDevice -> Task () deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d) >>| maybe (treturn ()) (flip removeTask topLevelTasks) d.deviceTask - >>| upd (filter ((==)d)) deviceStore + >>| upd (filter ((<>)d)) deviceStore @! () sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task () @@ -136,8 +136,7 @@ deviceTaskAcked dev i [{t & ident=i}:ts] [t:ackFirst ts] deviceTaskDelete :: MTaskDevice MTaskTask -> Task () -deviceTaskDelete dev task = sendMessages [MTTaskDel task.ident] dev - >>| upd (\ds->filter ((<>) dev) ds) deviceStore @! () +deviceTaskDelete dev task = sendMessages [MTTaskDel task.ident] dev @! () deviceTaskDeleteAcked :: MTaskDevice Int -> Task () deviceTaskDeleteAcked d i = withDevices d $ deleteTask diff --git a/Devices/mTaskTCP.icl b/Devices/mTaskTCP.icl index 4e3aba6..52832d6 100644 --- a/Devices/mTaskTCP.icl +++ b/Devices/mTaskTCP.icl @@ -5,6 +5,7 @@ import StdDebug import Devices.mTaskDevice import iTasks from Data.Tuple import appSnd +from Data.Maybe import fromMaybe from Text import class Text(indexOf), instance Text String derive class iTask TCPSettings @@ -27,20 +28,18 @@ instance MTaskDuplex TCPSettings where whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool) //We stop whileConnected _ _ (_,_,True) = (Ok "", Nothing, [], True) - //No new data and nothing to send whileConnected Nothing acc (_,[],_) = (Ok acc, Nothing, [], False) - //New data and possibly something to send - whileConnected (Just newdata) acc (msgs,send,sendStopped) - # (acc, nd) = process (acc +++ newdata) + whileConnected newdata acc (msgs,send,sendStopped) + # (acc, nd) = process (acc +++ fromMaybe "" newdata) | isEmpty nd && isEmpty send = (Ok acc, Nothing, [], False) = (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False) process :: String -> (String, [String]) process s = case indexOf "\n" s of -1 = (s, []) - i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i, size s))) + i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i+1, size s))) onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool)) onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing) diff --git a/client/interface.c b/client/interface.c index 0b994ea..9ddd214 100644 --- a/client/interface.c +++ b/client/interface.c @@ -4,7 +4,6 @@ #include #include -#include "chprintf.h" #include "interface.h" #include "ch.h" #include "hal.h" @@ -91,10 +90,7 @@ void setup(void) void debug(char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - chvprintf((BaseSequentialStream *)&SD3, fmt, ap); - va_end(ap); + (void)fmt; } void pdie(char *s) diff --git a/client/spec.c b/client/spec.c index 762eedc..8098a77 100644 --- a/client/spec.c +++ b/client/spec.c @@ -5,7 +5,8 @@ void spec_send(void) { write_byte('c'); - write_byte(0 | HAVELED << 0 | HAVEAIO << 1 | HAVEDIO << 2); + write_byte(0 | (HAVELED << 0) | (HAVEAIO << 1) | (HAVEDIO << 2)); write16(MAXTASKS); write16(MAXSDSS); + write_byte('\n'); } diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 16abbd0..716fc18 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -89,6 +89,7 @@ instance toString MTaskMSGRecv where toString (MTSDSDelAck i) = "SDS deleted with id: " +++ toString i toString (MTPub i v) = "Publish id: " +++ toString i +++ " value " +++ safePrint v + toString (MTDevSpec mt) = "Specification: " +++ printToString mt toString (MTMessage m) = m toString MTEmpty = "Empty message"