chiark / gitweb /
sort out !movpos crashing sometimes
authorian <ian>
Sun, 18 May 2008 11:59:36 +0000 (11:59 +0000)
committerian <ian>
Sun, 18 May 2008 11:59:36 +0000 (11:59 +0000)
hostside/commands.c
hostside/realtime.c
hostside/realtime.h

index 9b1205ced4271b58c9c264a12d77da08de46ddaf..7da070c4e52e3bfe2d2c0bdd27efc68008a9091f 100644 (file)
@@ -240,7 +240,7 @@ static int cmd_movpos(ParseState *ps, const CmdInfo *ci) {
   MUSTECR( ps_needsegmentperhaps(ps,&move,&movei) );
   MUSTECR( ps_needword(ps) );
   if (CTYPE(isdigit,*ps->thisword)) {
-    if (!move) badcmd(ps,"invalid movement specification");
+    if (!move) return badcmd(ps,"invalid movement specification");
     ps_pushbackword(ps);
     MUSTECR( ps_neednumber(ps,&poscomb_l,0,movei->n_poscombs,
                           "position number") );
@@ -259,11 +259,14 @@ static int cmd_movpos(ParseState *ps, const CmdInfo *ci) {
 
   MUSTECR( ps_neednoargs(ps) );
 
-  if (ci->xarg & CIXF_FORCE)
+  if (ci->xarg & CIXF_FORCE) {
+    if (!(sta_state < Sta_Resolving || sta_state == Sta_Manual))
+      return badcmd(ps,"movpos queueing arrangements not ready");
     MUSTECR( movpos_change(move,poscomb,ms,0) );
-  else
+  } else {
     MUSTECRPREDICT( safety_movposchange(move, poscomb, ci->xarg & CIXF_U,
                                        CMDPPC) );
+  }
 
   return 0;
 }
@@ -296,6 +299,29 @@ static int cmd_invert(ParseState *ps, const CmdInfo *ci) {
   return 0;
 }
 
+/*---------- general machinery and the command table ----------*/ 
+void command_doline(ParseState *ps, CommandInput *cmdi_arg) {
+  int r;
+
+  simlog("command-in %s\n",ps->remain);
+  simlog_flush();
+  current_cmd= 0;
+  current_cmd= some_needword_lookup(ps, toplevel_cmds, "command");
+  if (!current_cmd) return;
+  oprintf(UPO, "executing %s\n",current_cmd->name);
+  if (sta_state < Sta_Run && !(current_cmd->xarg & CIXF_ANYSTA)) {
+    oprintf(UPO,"ack %s InvalidState : layout not ready\n",current_cmd->name);
+    return;
+  }
+  r= current_cmd->fn(ps,current_cmd);
+  switch (r) {
+  case 0:  oprintf(UPO, "ack %s ok\n", current_cmd->name);                    break;
+  case EC_BadCmd:                                                    break;
+  default: oprintf(UPO, "ack %s %s\n", current_cmd->name, errorcodelist[r]);  break;
+  }
+}
+
 const CmdInfo toplevel_cmds[]= {
   { "!pic",       cmd_pic,        CIXF_ANYSTA|CIXF_FORCE   },
   { "!nmra",      cmd_nmra,       CIXF_ANYSTA              },
index ae8c804a599e5dcc43836a6f01db094f95c44126..8b246c855be3d5ac2cfa1428e23cc7fa08bf5367 100644 (file)
@@ -168,36 +168,13 @@ static void oprint_nmradata(const PicInsn *pi) {
   
 /*---------- command channel handling (oop_read, obc) ----------*/
 
-static const CmdInfo *ci;
-
 int vbadcmd(ParseState *ps, const char *fmt, va_list al) {
-  oprintf(UPO,"ack %s BadCmd : ", ci?ci->name:"?");
+  oprintf(UPO,"ack %s BadCmd : ", current_cmd?current_cmd->name:"?");
   ovprintf(UPO,fmt,al);
   oprintf(UPO,"\n");
   return EC_BadCmd;
 }
 
-static void command_doline(ParseState *ps, CommandInput *cmdi_arg) {
-  int r;
-
-  simlog("command-in %s\n",ps->remain);
-  simlog_flush();
-  ci= 0;
-  ci= some_needword_lookup(ps, toplevel_cmds, "command");
-  if (!ci) return;
-  oprintf(UPO, "executing %s\n",ci->name);
-  if (sta_state < Sta_Run && !(ci->xarg & CIXF_ANYSTA)) {
-    oprintf(UPO,"ack %s InvalidState : layout not ready\n",ci->name);
-    return;
-  }
-  r= ci->fn(ps,ci);
-  switch (r) {
-  case 0:  oprintf(UPO, "ack %s ok\n", ci->name);                    break;
-  case EC_BadCmd:                                                    break;
-  default: oprintf(UPO, "ack %s %s\n", ci->name, errorcodelist[r]);  break;
-  }
-}
-
 void oupicio(const char *dirn, const PicInsnInfo *pii, int obj, int v) {
   if (!pii->argsbits)
     oprintf(UPO, "picio %s %s\n", dirn, pii->name);
index f1aa19c21fac93ec0ea3c0ebf48b10386b4f5739..be9ed9047fa896d7912db9aefa3feceef6320884 100644 (file)
@@ -113,9 +113,9 @@ extern int picio_send_noise;
 
 #define UPO (&(cmdi.out))
 
-#define CIXF_U        0x00ffffu
-#define CIXF_ANYSTA   0x010000u
-#define CIXF_FORCE    0x020000u
+#define CIXF_U                 0x0000ffffu
+#define CIXF_FORCE             0x00010000u
+#define CIXF_ANYSTA            0x00020000u
 
 /*---------- from/for startup.c ----------*/
 
@@ -154,6 +154,8 @@ void ouhexi(const char *word, const Byte *command, int length);
 void ouhexo(const char *word, const Byte *command, int length);
 
 void serial_transmit(const PicInsn *pi);
+void command_doline(ParseState *ps, CommandInput *cmdi_arg);
+const CmdInfo *current_cmd;
 
 /*---------- for/from simulate.c ----------*/