-Subproject commit 1b51061da5972a0cca502403496c12d731093960
+Subproject commit 948f49f132f17f55b2ac49c2771df13d9aac3b48
connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task ()
connectDevice pf d = let ch = channels d in appendTopLevelTask 'DM'.newMap True
(pf d ch -||- catchAll (getSynFun d.deviceData ch) errorHandle)
- >>= \tid->withDevices d (\d->{d&deviceTask=Just tid,deviceError=Nothing}) @! ()
+ >>= \tid->withDevices d (\d->{d&deviceTask=Just tid,deviceError=Nothing})
+ >>| upd (\(r,s,ss)->(r,s++[MTSpec],ss)) ch
+ @! ()
where
errorHandle e = withDevices d (\d->{d&deviceTask=Nothing,deviceError=Just e})
deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d)
>>| maybe (treturn ()) (flip removeTask topLevelTasks) d.deviceTask
>>| upd (filter ((<>)d)) deviceStore
+// >>| upd (removeShares d) sdsStore
@! ()
sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
:: MTaskShareType = MTaskWithShare String | MTaskLens String
:: MTaskShare =
- {withTask :: String
+ {withTask :: [String]
,identifier :: Int
,realShare :: MTaskShareType
,value :: BCValue
//updateShare sh=:{withTask,identifier} a = getDeviceByName withTask
// >>= sendMessages [MTUpd identifier $ toString $ toByteCode a]
// >>| treturn sh
+//
+from StdFunc import flip
viewSharesGrid :: (Shared (Maybe MTaskShare)) [MTaskShare] -> Task [BCValue]
viewSharesGrid _ [] = viewInformation "No shares yet" [] []
viewSharesGrid cs sh = (allTasks [watch (getSDSShare m)\\m<-sh] <<@ NoUserInterface)
- >&^ \st->whileUnchanged st $ \mshs->enterChoice "" [ChooseFromGrid id]
+ >&^ \st->flip (<<@) NoUserInterface $ whileUnchanged st $ \mshs->enterChoice "" [ChooseFromGrid id]
[{MTaskShare|ss&value=s}\\s<-fromJust mshs & ss<-sh]
- >>* [OnValue (withValue $ \s->Just (set (Just s) cs))]
+// >>* [OnValue (withValue $ \s->Just (set (Just s) cs))]
@! fromJust mshs
viewShare :: MTaskShare -> Task BCValue
makeShare :: String Int BCValue -> Task MTaskShare
makeShare withTask identifier value = treturn
{MTaskShare
- |withTask=withTask
+ |withTask=[withTask]
,identifier=identifier
,value=value
,realShare=MTaskWithShare $ "mTaskSDS-" +++ toString identifier
void setup(void)
{
- palSetPadMode(GPIOG, 9, PAL_MODE_ALTERNATE(8)); // USART6 TX
- palSetPadMode(GPIOG, 14, PAL_MODE_ALTERNATE(8)); // USART6 RX
+// palSetPadMode(GPIOG, 9, PAL_MODE_ALTERNATE(8)); // USART6 TX
+// palSetPadMode(GPIOG, 14, PAL_MODE_ALTERNATE(8)); // USART6 RX
halInit();
chSysInit();
sdStart(&SD3, NULL);
-// sdStart(&SD6, NULL);
-
-// while(1){
-// sdPut(&SD3, sdGet(&SD6));
-// delay(50);
-// }
}
void debug(char *fmt, ...)
{
- (void)fmt;
+ write_byte('m');
+ for(unsigned int i = 0; i<strlen(fmt); i++){
+ write_byte(fmt[i]);
+ }
+ write_byte('\n');
+// (void)fmt;
}
void pdie(char *s)
sp--;
break;
#endif
-#if HAVELED == 1
+//#if HAVELED == 1
case BCLEDON: trace("LedOn(%d)", program[pc]);
led_on(stack[sp-1]);
sp--;
led_off(stack[sp-1]);
sp--;
break;
-#endif
+//#endif
default:
trace("unrecognized");
die("Unrecognized command: %d", program[pc-1]);
#define MSG_SDS_SPEC 's'
#define MSG_SDS_DEL 'a'
#define MSG_SDS_UPD 'u'
+#define MSG_SPEC 'c'
void read_message(void)
{
debug("Receiving a task");
task_register();
break;
+ case MSG_SPEC:
+ debug("Receiving a spec request");
+ spec_send();
+ break;
case '\0':
- die("Server closed connection");
+ debug("Server closed connection");
break;
case '\n':
break;
sds_init();
task_init();
debug("sending device spec");
- spec_send();
while(true){
//Check for newetasks
loop();
void spec_send(void)
{
- debug("Writing spec");
write_byte('c');
write_byte(0 | (HAVELED << 0) | (HAVEAIO << 1) | (HAVEDIO << 2));
write16(MAXTASKS);
write16(MAXSDSS);
write_byte('\n');
- debug("Done writing spec");
+ write_byte('\n');
}
memset(&tasks[ct], 0, sizeof(struct task));
//Read interval
tasks[ct].interval = read16();
+ debug("interval: %d\n", tasks[ct].interval);
//Interrupt task
if(is_interrupt_task(&tasks[ct])) {
| MTTaskDel Int
| MTSds Int String
| MTUpd Int String
+ | MTSpec
:: MTaskInterval
= OneShot
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
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
--- /dev/null
+delete tasks when deleting device
+make sure shares are assigned to correct task and not propagated
+let tasks have a unique name
+add field in task that denotes to which device it belongs