X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.icl;h=bd5572aeb16e794af8bd9b9cdcf8650b14d96bd2;hb=59c7c761163b0cc5215563644ca60e2a47b9c9a9;hp=c986ec5607b45425c45997d1d1a69545247b9b97;hpb=be3f747f775c05facb8a34cf0baba523401b88fb;p=mTask.git diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index c986ec5..bd5572a 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -41,15 +41,11 @@ import Text.Encodings.Base64 import Tasks.Examples encode :: MTaskMSGSend -> String -encode (MTTask to data) = "t" +++ tob +++ to16bit (size data) +++ data +++ "\n" - where - tob = case to of - OneShot = to16bit 0 - OnInterval i = to16bit i - OnInterrupt _ = abort "Interrupts not implemented yet" +encode (MTTask to data) = "t" +++ toByteCode to +++ to16bit (size data) +++ data +++ "\n" encode (MTTaskDel i) = "d" +++ to16bit i +++ "\n" encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n" encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n" +encode (MTSpec) = "c\n" import StdDebug decode :: String -> MTaskMSGRecv @@ -143,7 +139,7 @@ instance fromByteCode UserLED where fromByteCode s = conses{|*|} !! toInt s.[1] instance fromByteCode BCValue where fromByteCode s = parseBCValue s.[0] s instance toByteCode MTaskInterval where - toByteCode OneShot = toByteCode 0 + toByteCode OneShot = toByteCode (OnInterval 0) //Intervals have the first bit 0 and the rest is a 15 bit unsigned int toByteCode (OnInterval i) = {toChar $ i/256 bitand 127, toChar $ i rem 256} //Intervals have the first bit 1 and the rest is a 15 bit unsigned int @@ -159,9 +155,9 @@ instance fromByteCode MTaskInterval instance fromByteCode MTaskDeviceSpec where fromByteCode s = let c = toInt s.[0] in {MTaskDeviceSpec - |haveLed=c bitand 1 > 0 - ,haveAio=c bitand 2 > 0 - ,haveDio=c bitand 4 > 0 + |haveLed=(c bitand 1) > 0 + ,haveAio=(c bitand 2) > 0 + ,haveDio=(c bitand 4) > 0 ,maxTask=from16bit $ s % (1,3) ,maxSDS=from16bit $ s % (3,5) }