Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The function commands were not being interpreted correctly as part of
the DCC++ text based protocol stream. The wrong set of functions were
being enabled due to missing guards on the bit masking.
  • Loading branch information
atanisoft committed Mar 25, 2019
1 parent 342769f commit ce12795
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/LocomotiveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void LocomotiveManager::processFunction(const std::vector<String> arguments) {
// check this is a request for functions F13-F28
if(arguments.size() > 2) {
int secondaryFunctionByte = arguments[2].toInt();
if(functionByte & 0xDE) {
if((functionByte & 0xDE) == 0xDE) {
for(uint8_t funcID = 13; funcID <= 20; funcID++) {
loco->setFunction(funcID, bitRead(secondaryFunctionByte, funcID-13));
}
Expand All @@ -68,11 +68,11 @@ void LocomotiveManager::processFunction(const std::vector<String> arguments) {
// this is a request for functions FL,F1-F12
// for safety this guarantees that first nibble of function byte will always
// be of binary form 10XX which should always be the case for FL,F1-F12
if(functionByte & 0xA0) {
if((functionByte & 0xA0) == 0xA0) {
for(uint8_t funcID = 9; funcID <= 12; funcID++) {
loco->setFunction(funcID, bitRead(functionByte, funcID-9));
}
} else if(functionByte & 0xB0) {
} else if((functionByte & 0xB0) == 0xB0) {
for(uint8_t funcID = 5; funcID <= 8; funcID++) {
loco->setFunction(funcID, bitRead(functionByte, funcID-5));
}
Expand Down

0 comments on commit ce12795

Please sign in to comment.