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") );
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;
}
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 },
/*---------- 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);
#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 ----------*/
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 ----------*/