'\0' = MTEmpty
'\n' = MTEmpty
'm' = MTMessage x
+ 't' = MTTaskAdded (from16bit (x % (1,3)))
'u' = MTPub (from16bit (x % (1,3))) (x % (3,5))
_ = MTMessage x//abort ("Didn't understand message: " +++ join " " [toString (toInt c)\\c<-: x] +++ "\n")
instance toString MTaskMSGRecv where
toString (MTPub i v) = "Publish id: " +++ toString i
+++ " value " +++ safePrint v
+ toString (MTTaskAdded i) = "Task added with id: " +++ toString i
toString MTEmpty = "Empty message"
bclength :: BC -> Int
bclength (BCPush _) = 3
bclength (BCLab _) = 2
-bclength (BCSdsStore _) = 2
-bclength (BCSdsFetch _) = 2
-bclength (BCSdsPublish _) = 2
+bclength (BCSdsStore _) = 3
+bclength (BCSdsFetch _) = 3
+bclength (BCSdsPublish _) = 3
bclength (BCAnalogRead _) = 2
bclength (BCAnalogWrite _) = 2
bclength (BCDigitalRead _) = 2
toByteVal :: BC -> [Char]
toByteVal b
-# bt = toChar $ consIndex{|*|} b + 1
+# bt = toChar $ consIndex{|*|} b
= [bt:case b of
(BCPush i) = i
(BCLab i) = [toChar i]
- (BCSdsStore i) = [toChar i]
- (BCSdsFetch i) = [toChar i]
- (BCSdsPublish i) = [toChar i]
+ (BCSdsStore i) = [c\\c<-:to16bit i]
+ (BCSdsFetch i) = [c\\c<-:to16bit i]
+ (BCSdsPublish i) = [c\\c<-:to16bit i]
(BCAnalogRead i) = [toChar i]
(BCAnalogWrite i) = [toChar i]
(BCDigitalRead i) = [toChar i]
b <++> retrn [BCJmpF else] <++> t
<++> retrn [BCJmp endif,BCLab else] <++> e <++> retrn [BCLab endif]
-instance noOp ByteCode where noOp = mempty
+instance noOp ByteCode where noOp = retrn [BCNop]
withLabel :: (Int -> (ByteCode b q)) -> ByteCode b q
withLabel f = BC \s->let [fresh:fs] = s.freshl