loconet: report warning if slot isn't usable, stop sending fast clock sync if slot isn't usable

Dieser Commit ist enthalten in:
Reinder Feenstra 2022-10-20 23:02:28 +02:00
Ursprung ff7995abff
Commit 8f584a4dbc
5 geänderte Dateien mit 52 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -518,6 +518,33 @@ void Kernel::receive(const Message& message)
Log::log(m_logId, LogMessage::C2004_CANT_GET_FREE_SLOT);
});
}
else if(longAck.respondingOpCode() == OPC_RQ_SL_DATA && longAck.ack1 == 0 && lastSentMessage().opCode == OPC_RQ_SL_DATA)
{
const uint8_t slot = static_cast<const RequestSlotData&>(lastSentMessage()).slot;
if(isLocoSlot(slot))
{
EventLoop::call(
[this, slot]()
{
Log::log(m_logId, LogMessage::W2006_COMMAND_STATION_DOES_NOT_SUPPORT_LOCO_SLOT_X, slot);
});
}
else if(slot == SLOT_FAST_CLOCK)
{
m_fastClockSupported = false;
if(m_config.fastClockSyncEnabled)
stopFastClockSyncTimer();
EventLoop::call(
[this, stoppedFastClockSyncTimer=m_config.fastClockSyncEnabled]()
{
Log::log(m_logId, LogMessage::W2007_COMMAND_STATION_DOES_NOT_SUPPORT_THE_FAST_CLOCK_SLOT);
if(stoppedFastClockSyncTimer)
Log::log(m_logId, LogMessage::N2003_STOPPED_SENDING_FAST_CLOCK_SYNC);
});
}
}
else if(m_lncvActive && m_onLNCVReadResponse &&
longAck.respondingOpCode() == OPC_IMM_PACKET && longAck.ack1 == 0x7F &&
Uhlenbrock::LNCVWrite::check(lastSentMessage()))
@ -1120,7 +1147,7 @@ void Kernel::stopFastClockSyncTimer()
void Kernel::fastClockSyncTimerExpired(const boost::system::error_code& ec)
{
if(ec || !m_config.fastClockSyncEnabled)
if(ec || !m_config.fastClockSyncEnabled || !m_fastClockSupported)
return;
send(RequestSlotData(SLOT_FAST_CLOCK));

Datei anzeigen

@ -141,6 +141,7 @@ class Kernel
std::function<void()> m_onIdle;
boost::asio::steady_timer m_fastClockSyncTimer;
bool m_fastClockSupported = true;
bool m_lncvActive = false;
uint16_t m_lncvModuleId = 0;

Datei anzeigen

@ -57,6 +57,7 @@ Settings::Settings(Object& _parent, std::string_view parentPropertyName)
Attributes::addMinMax(locomotiveSlots, SLOT_LOCO_MIN, SLOT_LOCO_MAX);
m_interfaceItems.add(locomotiveSlots);
Attributes::addEnabled(fastClockSyncEnabled, true);
//Attributes::addGroup(fastClockSyncEnabled, Group::fastClockSync);
m_interfaceItems.add(fastClockSyncEnabled);
@ -109,6 +110,7 @@ void Settings::commandStationChanged(LocoNetCommandStation value)
{
const bool isCustom = (value == LocoNetCommandStation::Custom);
// locomotive slots:
switch(value)
{
case LocoNetCommandStation::Custom:
@ -123,8 +125,22 @@ void Settings::commandStationChanged(LocoNetCommandStation value)
locomotiveSlots = 32;
break;
}
Attributes::setEnabled(locomotiveSlots, isCustom);
// fast clock:
switch(value)
{
case LocoNetCommandStation::Custom:
case LocoNetCommandStation::DigikeijsDR5000:
Attributes::setEnabled(fastClockSyncEnabled, true);
break;
case LocoNetCommandStation::UhlenbrockIntellibox:
case LocoNetCommandStation::UhlenbrockIBCOM:
fastClockSyncEnabled = false;
Attributes::setEnabled(fastClockSyncEnabled, false);
break;
}
}
}

Datei anzeigen

@ -110,6 +110,7 @@ enum class LogMessage : uint32_t
N1026_IMPORTED_WORLD_SUCCESSFULLY = LogMessageOffset::notice + 1026,
N2001_SIMULATION_NOT_SUPPORTED = LogMessageOffset::notice + 2001,
N2002_NO_RESPONSE_FROM_LNCV_MODULE_X_WITH_ADDRESS_X = LogMessageOffset::notice + 2002,
N2003_STOPPED_SENDING_FAST_CLOCK_SYNC = LogMessageOffset::notice + 2003,
N9001_STARTING_SCRIPT = LogMessageOffset::notice + 9001,
N9999_X = LogMessageOffset::notice + 9999,
@ -122,6 +123,8 @@ enum class LogMessage : uint32_t
W2003_COMMAND_STATION_DOESNT_SUPPORT_X_SPEEDSTEPS_USING_X = LogMessageOffset::warning + 2003,
W2004_INPUT_ADDRESS_X_IS_INVALID = LogMessageOffset::warning + 2004,
W2005_OUTPUT_ADDRESS_X_IS_INVALID = LogMessageOffset::warning + 2005,
W2006_COMMAND_STATION_DOES_NOT_SUPPORT_LOCO_SLOT_X = LogMessageOffset::warning + 2006,
W2007_COMMAND_STATION_DOES_NOT_SUPPORT_THE_FAST_CLOCK_SLOT = LogMessageOffset::warning + 2007,
W2018_TIMEOUT_NO_ECHO_WITHIN_X_MS = LogMessageOffset::warning + 2018,
W9999_X = LogMessageOffset::warning + 9999,

Datei anzeigen

@ -392,6 +392,7 @@ message:N1025=Exported world successfully
message:N1026=Imported world successfully
message:N2001=Simulation not supported
message:N2002=No response from LNCV module %1 with address %2
message:N2003=Stopped sending fast clock sync
message:N9001=Starting script
message:N9999=%1
message:W1001=Discovery disabled, only allowed on port %1
@ -402,6 +403,8 @@ message:W2002=Command station doesn't support functions above F%1
message:W2003=Command station doesn't support %1 speedsteps using %2
message:W2004=Input address %1 is invalid
message:W2005=Output address %1 is invalid
message:W2006=Command station does not support loco slot %1
message:W2007=Command station does not support the fast clock slot
message:W2018=Timeout, no echo within %1ms
message:W9999=%1