chiark / gitweb /
handle NULs more sanely
authorian <ian>
Sun, 11 May 2008 14:30:18 +0000 (14:30 +0000)
committerian <ian>
Sun, 11 May 2008 14:30:18 +0000 (14:30 +0000)
cebpic/README.protocol
hostside/retransmit.c
hostside/startup.c

index 79db9a5bdaa1af9c94f1b6412992b35b187530ba..1f59b99794b35c5505cc9e2691b47605c81f4189 100644 (file)
@@ -71,6 +71,7 @@ From PIC to host:
  < 0 000 0100             (ENQ)        WAGGLED   Pin changed according to WAGGLE
  < 0 0100 PPP             (20+)        POINTED   Point change done using capacitor P
  < 0 0101 PPP             (28+)        CHARGED   Point capacitor P is now charged
+ < 0 00000 00                  NUL       Junk, prob because layout turned off
  < 0 00000 FF                  NMRADONE  Have processed F NMRADATA message(s)
 
  < 0000 1010              (LF)  } debugging output        0x0a (newline) and
index 0a60bfdaea721487cba24f57c90a02cc9db8c2f5..ab3546324a06c76e06c2127018d3316957b83f99 100644 (file)
@@ -140,7 +140,7 @@ void retransmit_urgent_cancel(RetransmitUrgentNode *urg) {
 
 
 void on_pic_nmradone(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
-  if (!objnum) die("PIC sent NUL!");
+  assert(objnum);
   if (sta_state == Sta_Run || sta_state == Sta_Manual)
     while (objnum--)
       retransmit_something();
index 27091a081acb37f904cce9e9f5bbc5d5832948ce..d933df1b226dc0d0976ee92372c9882fcef79e29 100644 (file)
@@ -47,14 +47,17 @@ oprintf(DUPO("ip") " %ld.%06ld\n", now.tv_sec, now.tv_usec);
   timefor_ping(0);
 }
 
+static void sta_startup_manual(void) {
+  waggle_startup_manual();
+  retransmit_start();
+  oprintf(UPO, "stastate %s\n", stastatelist[sta_state]);
+}
+
 void sta_startup(void) {
-  if (sta_state != Sta_Manual) {
-    sta_goto(Sta_Flush);
-  } else {
-    waggle_startup_manual();
-    retransmit_start();
-  }
+  if (sta_state == Sta_Manual) sta_startup_manual();
+  else sta_goto(Sta_Flush);
 }
+
 void sta_finalising_done(void) { sta_goto(Sta_Run); }
 
 static void sta_goto(StartupState new_state) {
@@ -191,6 +194,15 @@ void serial_moredata(PicInsn *buf) {
   pii->input_fn(pii,buf,obj);
 }
 
+void on_pic_nul(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
+  /* layout turned off, probably */
+  if (sta_state == Sta_Manual) return;
+  enco_pic_off(&piob);
+  serial_transmit(&piob);
+  sta_goto(Sta_Flush);
+  return;
+}
+
 void on_pic_pong(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
   if (sta_state == Sta_Manual)
     return;