mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-07-08 14:48:55 +02:00
Make sniffer more robust against loop() not keeping up. Eliminate fetch flag as the list size does say it all
This commit is contained in:
parent
a6c86bc294
commit
2797ca0d1b
18
Sniffer.cpp
18
Sniffer.cpp
@ -196,19 +196,25 @@ void IRAM_ATTR Sniffer::processInterrupt(int32_t capticks, bool posedge) {
|
||||
inpacket = false;
|
||||
dcclen = currentbyte+1;
|
||||
debugfield = bitfield;
|
||||
// put it into the out packet
|
||||
if (fetchflag) {
|
||||
// not good, should have been fetched
|
||||
// blink_diag(1);
|
||||
packeterror(); // or better?
|
||||
// We have something we want to give to the outpacket queue
|
||||
// Check length of outpacket queue
|
||||
if (outpacket.size() > 3) {
|
||||
// not good, these should have been fetched
|
||||
// the arbitraty number to check is THREE (see the holy grail)
|
||||
// blink_diag(1); DO NOT DO THIS HERE -> will crash
|
||||
packeterror(); // or what to do better?
|
||||
// take emergency action:
|
||||
while (!outpacket.empty()) {
|
||||
outpacket.pop_front();
|
||||
}
|
||||
}
|
||||
lastendofpacket = millis();
|
||||
DCCPacket temppacket(dccbytes, dcclen);
|
||||
if (!(temppacket == prevpacket)) {
|
||||
// we have something new to offer to the fetch routine
|
||||
// put it into the outpacket queue
|
||||
outpacket.push_back(temppacket);
|
||||
prevpacket = temppacket;
|
||||
fetchflag = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -51,9 +51,6 @@ public:
|
||||
p = outpacket.front();
|
||||
outpacket.pop_front();
|
||||
}
|
||||
if (fetchflag) {
|
||||
fetchflag = false; // (data has been fetched)
|
||||
}
|
||||
interrupts();
|
||||
return p;
|
||||
};
|
||||
@ -71,7 +68,6 @@ private:
|
||||
bool inpacket = false;
|
||||
// these vars are used as interface to other parts of sniffer
|
||||
byte halfbitcounter = 0;
|
||||
bool fetchflag = false;
|
||||
std::list<DCCPacket> outpacket;
|
||||
DCCPacket prevpacket;
|
||||
volatile unsigned long lastendofpacket = 0; // timestamp millis
|
||||
|
Loading…
x
Reference in New Issue
Block a user