mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 15:46:14 +01:00
pom read timeout
This commit is contained in:
parent
a0a503ad7d
commit
44869a549d
18
Railcom.cpp
18
Railcom.cpp
|
@ -147,7 +147,7 @@ Railcom::Railcom(uint16_t blockvpin) {
|
|||
}
|
||||
uint16_t Railcom::expectLoco=0;
|
||||
uint16_t Railcom::expectCV=0;
|
||||
uint16_t Railcom::expectWait=0;
|
||||
unsigned long Railcom::expectWait=0;
|
||||
ACK_CALLBACK Railcom::expectCallback=0;
|
||||
|
||||
|
||||
|
@ -183,22 +183,20 @@ void Railcom::process(uint8_t * inbound, uint8_t length) {
|
|||
byte type=(packet>>8) & 0x0F;
|
||||
byte data= packet & 0xFF;
|
||||
if (type==RMOB_POM) {
|
||||
DIAG(F("POM READ loco=%d cv(%d)=%d/0x%x"), expectLoco, expectCV,data,data);
|
||||
// DIAG(F("POM READ loco=%d cv(%d)=%d/0x%x"), expectLoco, expectCV,data,data);
|
||||
expectCallback(data);
|
||||
expectCV=0;
|
||||
}
|
||||
}
|
||||
if (expectCV) { // still waiting
|
||||
expectWait--;
|
||||
if (expectWait==0) {
|
||||
DIAG(F("POM READ loco=%d cv(%d) FAIL"), expectLoco, expectCV);
|
||||
expectCallback(-1);
|
||||
expectCV=0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (expectCV && (millis()-expectWait)> POM_READ_TIMEOUT) { // still waiting
|
||||
expectCallback(-1);
|
||||
expectCV=0;
|
||||
}
|
||||
|
||||
|
||||
auto v1=GETHIGHFLASH(decode,inbound[0]);
|
||||
auto v2=(length>1) ? GETHIGHFLASH(decode,inbound[1]):INV;
|
||||
uint16_t packet=(v1<<6) | (v2 & 0x3f);
|
||||
|
|
|
@ -36,12 +36,14 @@ class Railcom {
|
|||
static void anticipate(uint16_t loco, uint16_t cv, ACK_CALLBACK callback) {
|
||||
expectLoco=loco;
|
||||
expectCV=cv;
|
||||
expectWait=10; // channel3 packets
|
||||
expectWait=millis(); // start of timeout
|
||||
expectCallback=callback;
|
||||
};
|
||||
|
||||
private:
|
||||
static uint16_t expectCV,expectLoco,expectWait;
|
||||
static const unsigned long POM_READ_TIMEOUT=500; // as per spec
|
||||
static uint16_t expectCV,expectLoco;
|
||||
static unsigned long expectWait;
|
||||
static ACK_CALLBACK expectCallback;
|
||||
void noData();
|
||||
uint16_t vpin;
|
||||
|
|
Loading…
Reference in New Issue
Block a user