Skip to content

Commit

Permalink
Correct high bit long addr
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed Oct 22, 2024
1 parent a849ddd commit d25173e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Railcom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,13 @@ void Railcom::process(uint8_t * inbound, uint8_t length) {
haveLow=true;
packetsWithNoData=0;
}
else if (type==RMOB_EXT) {
return; /* ignore*/
}
else {
// channel1 is unreadable so maybe multiple locos in block
else {
// channel1 is unreadable or not loco address so maybe multiple locos in block
if (length>2 && GETHIGHFLASH(decode,inbound[0])!=INV) {
// it looks like we have channel2 data
auto thisLoco=DCCWaveform::getRailcomLastLocoAddress();
if (Diag::RAILCOM) DIAG(F("c2=%d"),thisLoco);
if (thisLoco==lastChannel1Loco) return;
if (thisLoco) DCC::setLocoInBlock(thisLoco,vpin,false); // this loco is in block, but not exclusive
return;
}
Expand All @@ -204,9 +202,10 @@ void Railcom::process(uint8_t * inbound, uint8_t length) {
return;
}
if (haveHigh && haveLow) {
uint16_t thisLoco=((holdoverHigh<<8)| holdoverLow);
uint16_t thisLoco=((holdoverHigh<<8)| holdoverLow) & 0x7FFF; // drop top bit
if (thisLoco!=lastChannel1Loco) {
// the exclusive DCC call is quite expensive, we dont want to call it every packet
if (Diag::RAILCOM) DIAG(F("h=%x l=%xc1=%d"),holdoverHigh, holdoverLow,thisLoco);
DCC::setLocoInBlock(thisLoco,vpin,true); // only this loco is in block
lastChannel1Loco=thisLoco;
}
Expand Down

0 comments on commit d25173e

Please sign in to comment.