Skip to content

Commit

Permalink
Check both bits 7 and 6 in imm packet to get length and address of de…
Browse files Browse the repository at this point in the history
…coder address.
  • Loading branch information
Pugwash1 committed Jan 23, 2020
1 parent 822e4e1 commit f1df781
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions java/src/jmri/jmrix/loconet/SlotManager.java
Expand Up @@ -430,16 +430,18 @@ int getDirectFunctionAddress(LocoNetMessage m) {
}
int addr = -1;
// check long address
if ((m.getElement(5) & 0x40) != 0) {
addr = (m.getElement(5) & 0x3F) * 256 + (m.getElement(6) & 0xFF);
if ((m.getElement(4) & 0x02) != 0) {
addr += 128; // and high bit
}
} else {
if ((m.getElement(4) & 0x01) == 0) { //bit 7=0 short
addr = (m.getElement(5) & 0xFF);
if ((m.getElement(4) & 0x01) != 0) {
addr += 128; // and high bit
}
} else if ((m.getElement(5) & 0x40) == 0x40) { // bit 7 = 1 if bit 6 = 1 then long
addr = (m.getElement(5) & 0x3F) * 256 + (m.getElement(6) & 0xFF);
if ((m.getElement(4) & 0x02) != 0) {
addr += 128; // and high bit
}
} else { // accessory decoder or extended accessory decoder
addr = (m.getElement(5) & 0x3F);
}
return addr;
}
Expand Down Expand Up @@ -472,11 +474,11 @@ int getDirectDccPacket(LocoNetMessage m) {
int start;
int high = m.getElement(4);
// check long or short address
if ((m.getElement(5) & 0x40) != 0) {
if ((m.getElement(4) & 0x01) == 1 && (m.getElement(5) & 0x40) == 0x40 ) { //long address bit 7 im1 = 1 and bit6 im1 = 1
start = 7;
high = high >> 2;
n = n - 2;
} else {
} else { //short or accessory
start = 6;
high = high >> 1;
n = n - 1;
Expand Down

0 comments on commit f1df781

Please sign in to comment.