mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
Turnout notification handling enhanced.
Ensure that the <H> message is sent on the serial USB (to JMRI) whenever the turnout is closed or thrown, even if the request didn't originate on the serial USB.
This commit is contained in:
parent
7f6173825f
commit
b4a3b503bc
|
@ -679,25 +679,29 @@ bool DCCEXParser::parseT(Print *stream, int16_t params, int16_t p[])
|
|||
// turnout 1 or T=THROW, 0 or C=CLOSE
|
||||
case 1: case 0x54: // 1 or T
|
||||
if (!Turnout::setClosed(p[0], false)) return false;
|
||||
p[1] = 1;
|
||||
break;
|
||||
case 0: case 0x43: // 0 or C
|
||||
if (!Turnout::setClosed(p[0], true)) return false;
|
||||
p[1] = 0;
|
||||
break;
|
||||
#else
|
||||
// turnout 0 or T=THROW,1 or C=CLOSE
|
||||
case 0: case 0x54: // 0 or T
|
||||
if (!Turnout::setClosed(p[0], false)) return false;
|
||||
p[1] = 0;
|
||||
break;
|
||||
case 1: case 0x43: // 1 or C
|
||||
if (!Turnout::setClosed(p[0], true)) return false;
|
||||
p[1] = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
// Send acknowledgement to caller, and to Serial.
|
||||
StringFormatter::send(stream, F("<H %d %d>\n"), p[0], p[1]);
|
||||
if (stream != &Serial) StringFormatter::send(Serial, F("<H %d %d>\n"), p[0], p[1]);
|
||||
// Send acknowledgement to caller if the command was not received over Serial (acknowledgement
|
||||
// messages on Serial are sent by the Turnout class).
|
||||
if (stream != &Serial) StringFormatter::send(stream, F("<H %d %d>\n"), p[0], p[1]);
|
||||
return true;
|
||||
|
||||
default: // Anything else is some kind of create function.
|
||||
|
|
|
@ -127,6 +127,11 @@ const int16_t HASH_KEYWORD_VPIN=-415;
|
|||
RMFT2::turnoutEvent(id, closeFlag);
|
||||
#endif
|
||||
|
||||
// Send message to JMRI etc. over Serial USB. This is done here
|
||||
// to ensure that the message is sent when the turnout operation
|
||||
// is not initiated by a Serial command.
|
||||
StringFormatter::send(Serial, F("<H %d %d>\n"), id, closeFlag);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
|
@ -466,7 +466,8 @@ public:
|
|||
}
|
||||
|
||||
bool activate(bool close) override {
|
||||
LCN::send('T', _turnoutData.id, close);
|
||||
// Assume that the LCN command still uses 1 for throw and 0 for close...
|
||||
LCN::send('T', _turnoutData.id, !close);
|
||||
// The _turnoutData.closed flag should be updated by a message from the LCN master, later.
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user