From: ian Date: Wed, 14 Jun 2006 17:33:55 +0000 (+0000) Subject: retransmit.c and safety.c now compile but loads of link errors for unwritten stuff X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=a3fae41292a1150e3eac2727d533250593879dcd;p=trains.git retransmit.c and safety.c now compile but loads of link errors for unwritten stuff --- diff --git a/hostside/.cvsignore b/hostside/.cvsignore index 7536abf..34d7554 100644 --- a/hostside/.cvsignore +++ b/hostside/.cvsignore @@ -9,3 +9,4 @@ proto-expanded auproto-* gui-plan-bot selectors.h +retransmit-table.h diff --git a/hostside/Makefile b/hostside/Makefile index 8650c61..d6646dc 100644 --- a/hostside/Makefile +++ b/hostside/Makefile @@ -1,6 +1,6 @@ # -AUTOINCS= auproto-pic.h layoutinfo.h selectors.h +AUTOINCS= auproto-pic.h layoutinfo.h selectors.h retransmit-table.h TARGETS= hostside-old gui-plan-bot realtime include ../common.make @@ -22,9 +22,10 @@ on-bessar: $(TARGETS) %.on-bessar: % RSYNC_RSH=fsh rsync $^ $(BESSAR) -realtime: realtime.o startup.o cdumgr.o \ +realtime: realtime.o startup.o cdumgr.o safety.o \ cmdinput.o obc.o eventhelp.o \ utils.o serialio.o parseutils.o auproto-pic.o \ + ../layout/ours.layout-data.o \ __oop-read-copy.o -loop $(LINK) @@ -43,7 +44,7 @@ auproto-pic.c auproto-pic.h: auproto-%: \ layoutinfo.h: ../layout/ours.layout-data.c Makefile sed -e '/^#include/,$$d' $< $o -selectors.h: selectors.h.gen +selectors.h retransmit-table.h: %: %.gen ./$< $o safety: safety.o utils.o trackloc.o ../layout/ours.layout-data.o diff --git a/hostside/hostside.h b/hostside/hostside.h index b6fbdc6..d350c07 100644 --- a/hostside/hostside.h +++ b/hostside/hostside.h @@ -17,15 +17,4 @@ struct OrdinaryPicMessage { int operand_bits; /* 0: no operand. >=7, insn is a 2-byte message */ }; -/*---------- from retransmit.c ----------*/ - -struct RetransmitNode { - /* set by caller: */ - PicInsn pi; - /* internal: */ -}; - -void retransmit_queue(RetransmitNode *rn); -void retransmit_cancel(RetransmitNode *rn); - #endif diff --git a/hostside/realtime.h b/hostside/realtime.h index 2aa2b3b..fbaafb6 100644 --- a/hostside/realtime.h +++ b/hostside/realtime.h @@ -6,7 +6,9 @@ #define REALTIME_H #include "daemons.h" +#include "safety.h" #include "auproto-pic.h" +#include "dliste.h" #include #include @@ -19,17 +21,28 @@ /*---------- from retransmit.c ----------*/ -typedef struct RetransmitNode RetransmitNode; -struct RetransmitNode { - /* set by caller: */ - PicInsn pi; - /* internal: */ - unsigned long speedyduetime; - struct { RetransmitNode *back, *next; } relaxed, speedy; +typedef struct RetransmitRelaxedNode RetransmitRelaxedNode; +typedef union RetransmitUrgentNode RetransmitUrgentNode; +typedef unsigned Retransmit__Time; + +struct RetransmitRelaxedNode { + PicInsn pi; /* callers must touch only this */ + DLIST_NODE(RetransmitRelaxedNode) rr; +}; +union RetransmitUrgentNode { + PicInsn pi; /* callers must touch only this */ + struct { + RetransmitRelaxedNode relaxed; + int ix; + Retransmit__Time when; + DLIST_NODE(RetransmitUrgentNode) queue; + } u; }; -void retransmit_queue(RetransmitNode *rn); -void retransmit_cancel(RetransmitNode *rn); +void retransmit_relaxed_queue(RetransmitRelaxedNode *rn); +void retransmit_relaxed_cancel(RetransmitRelaxedNode *rn); +void retransmit_urgent_queue(RetransmitUrgentNode *rn); +void retransmit_urgent_cancel(RetransmitUrgentNode *rn); /*---------- global variables, in realtime.c ----------*/ diff --git a/hostside/retransmit-table.h.gen b/hostside/retransmit-table.h.gen new file mode 100755 index 0000000..781bd26 --- /dev/null +++ b/hostside/retransmit-table.h.gen @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +$count= 20; +$exp= 1.3; +$first= 1.0; + +print <> 1) +#include "realtime.h" +#include "retransmit-table.h" -typedef struct { - DLIST2_HEAD(RetransmitUrgentNode) queue; /* msgs transmitted ix times */ - Retransmit__Time interval; /* interval after this retransmission */ -} PerSpeedyTrans; +#define RETRANSMIT_TIME_SIGNED_MAX ((~(Retransmit__Time)0) >> 1) static const PicInsn linefill= { { 0xff, 0x7f }, 2 }; static DLIST2_HEAD(RetransmitRelaxedNode) relaxed; static elapsed; -static PerSpeedyTrans speedies[RETRANS_SPEEDYCOUNT]; +static PerSpeedyTrans speedies[] = SPEEDIESINIT; static void retransmit_this(const PicInsn *pi) { serial_transmit(pi); @@ -69,7 +64,7 @@ static void retransmit_something() { ix++, spd++) { urg= spd->head; if (!urg) continue; - if (elapsed - urg->u.when > HALFWAY) continue; + if (elapsed - urg->u.when > RETRANSMIT_TIME_SIGNED_MAX) continue; /* found one to transmit: */ DLIST2_REMOVE(spd->queue,urg,u.queue); diff --git a/hostside/safety.c b/hostside/safety.c index 41c1618..8edec10 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -4,8 +4,7 @@ #include #include -#include "layoutinfo.h" -#include "safety.h" +#include "realtime.h" static void seg_clear_stale(SegmentState *seg) { if (!seg->tr_updated) { @@ -283,7 +282,7 @@ void safety_requestspeed(TrainNum tran, long newspeed) { logmsg(ec, tran, NOTA(Segment), "countermanded motion start"); } setspeed(tran, oldspeed); - oprintf(UPO, "countermanded %s %l %l\n", + oprintf(UPO, "countermanded %s %ld %ld\n", info_trains[tran].pname, oldspeed, newspeed); ec= lay_train(tran, 0); if (ec) diff --git a/hostside/startup.c b/hostside/startup.c index 8a5b98b..9f8a0fe 100644 --- a/hostside/startup.c +++ b/hostside/startup.c @@ -200,6 +200,7 @@ void on_pic_detect1(const PicInsnInfo *pii, const PicInsn *pi, int segn) { void on_pic_nmradone(const PicInsnInfo *pii, const PicInsn *pi, int objnum) { if (sta_state <= Sta_Settling) return; if (sta_state != Sta_Run) die("PIC sent NMRADONE in Resolving"); + /* fixme transmit something else (move this to another file?) */ }