gui-plan-bot
selectors.h
errorcodes.h
+stastate.h
retransmit-table.h
record-l.[ch]
record-y.[ch]
#
AUTOINCS= auproto-pic.h layoutinfo.h selectors.h retransmit-table.h \
- errorcodes.h
+ errorcodes.h stastate.h
TARGETS= hostside-old gui-plan-bot realtime
include ../common.make
layoutinfo.h: ../layout/ours.layout-data.c Makefile
sed -e '/^#include/,$$d' $< $o
-selectors.h retransmit-table.h errorcodes.h: %: %.gen
+selectors.h retransmit-table.h errorcodes.h stastate.h: %: %.gen
(echo "/*autogenerated*/" && ./$<) $o
safety: safety.o utils.o trackloc.o ../layout/ours.layout-data.o
$v{yn}= $yval;
$v{dname}= $dname;
$v{cname}= $cname;
+ $v{noiselevel}=
+ ($cname =~ m/nmradone/ ? 3 :
+ $cname =~ m/p[io]ng/ ? 2 :
+ $cname =~ m/detect/ ? 1 :
+ 0);
$v{cnameyn}= $cname.$yval;
$v{cnameynu}= uc($cname.$yval);
$v{opcode}= b2xh($opcode, 0);
/*---------- global variables ----------*/
CommandInput cmdi;
+int picio_send_noise= 1;
static const char *device= "/dev/ttya0";
void serial_transmit(const PicInsn *pi) {
const PicInsnInfo *pii;
- int objnum;
+ int objnum, suppress=0;
if ((pi->d[0] & 0xf8) == 0x90) {
SegmentNum segn;
}
oprintf(UPO,">\n");
} else if (pi->d[0] == 0xff) {
- oprint_nmradata(pi);
+ if (picio_send_noise < 3)
+ suppress= 1;
+ else
+ oprint_nmradata(pi);
} else {
picinsn_decode(pi, pic_command_infos, &pii, &objnum);
if (!pii)
oprintf(UPO, "picio out unknown\n");
+ else if (pii->noiselevel > picio_send_noise)
+ suppress= 1;
else
oupicio("out",pii,objnum);
}
- ouhex("picioh out", pi->d, pi->l);
+ if (!suppress)
+ ouhex("picioh out", pi->d, pi->l);
/* note that the serial port is still in nonblocking mode. if
* we ever buffer up far enough that the kernel wants to make us
/*---------- global variables, in realtime.c ----------*/
extern CommandInput cmdi;
+extern int picio_send_noise;
#define UPO (&(cmdi.out))
/*---------- from/for startup.c ----------*/
-typedef enum { /* sta_toev ping_toev */
- Sta_Flush, /* R 300 I ? */
- Sta_Off, /* I ? I ? */
- Sta_Ping, /* I ? I ? */
- Sta_Fault, /* I ? R set */
- Sta_Settling, /* I ? R set */
- Sta_Resolving, /* I ? R set */
- Sta_Run /* I ? R set */
-} StartupState;
+#include "stastate.h"
void sta_startup(void);
void serial_moredata(PicInsn *buf);
extern StartupState sta_state;
+extern const char *const stastatelist[];
/*---------- from/for record.c ----------*/
}
const PicInsnInfo pic_command_infos[]= {
- { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, 0 }, @h2p@
+ { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, 0 }, @h2p@
{ 0 }
};
const PicInsnInfo pic_reply_infos[]= {
- { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, on_pic_@cnameyn@ },@p2h@
+ { "@cnameyn@", @opcodeyn@, @opcodemaskyn@, @arglen@, @noiselevel@, on_pic_@cnameyn@ },@p2h@
{ 0 }
};
struct PicInsnInfo {
const char *name;
Byte opcode, mask;
- int argbits;
+ int argbits, noiselevel;
PicInputFn *input_fn;
};
#include "realtime.h"
+const char *const stastatelist[]= DEFINE_STASTATE_DATA;
StartupState sta_state;
static TimeoutEvent sta_toev;
sta_state= new_state;
/* notify various people: */
- oprintf(UPO, "stastate %d\n", sta_state);
+ oprintf(UPO, "stastate %s\n", stastatelist[sta_state]);
/* ... add others here. */
}
void serial_moredata(PicInsn *buf) {
const PicInsnInfo *pii;
- int objnum;
+ int objnum, suppress;
Byte *ep;
/* Called when more data is received from PICs.
found_end:
/* Aha! */
buf->l= ep - buf->d + 1;
- ouhex("picioh in msg", buf->d, buf->l);
picinsn_decode(buf, pic_reply_infos, &pii, &objnum);
+ suppress= pii && pii->noiselevel > picio_send_noise;
+ if (!suppress)
+ ouhex("picioh in msg", buf->d, buf->l);
if (!pii) { oprintf(UPO, "picio in unknown\n"); return; }
- oupicio("in",pii,objnum);
+ if (!suppress)
+ oupicio("in",pii,objnum);
pii->input_fn(pii,buf,objnum);
}
--- /dev/null
+#!/bin/sh
+
+set -e
+Sta () { l="$l $1"; }
+
+ # sta_toev ping_toev
+ Sta Flush # R 300 I ?
+ Sta Off # I ? I ?
+ Sta Ping # I ? I ?
+ Sta Fault # I ? R set
+ Sta Settling # I ? R set
+ Sta Resolving # I ? R set
+ Sta Run # I ? R set
+
+echo 'typedef enum {'
+for s in $l; do echo " Sta_$s,"; done
+echo '} StartupState;
+#define DEFINE_STASTATE_DATA \'
+printf ' { '
+for s in $l; do printf '"%s",' $s; done
+echo '0 }'