From 386f36a0838dede0084957fcab6924ba05b5a5fd Mon Sep 17 00:00:00 2001 From: hobbyquaker Date: Wed, 14 Oct 2026 20:35:14 +0200 Subject: [PATCH] hs485d: create the channels of a new device with their channel class SetDeviceDescription() built every channel of a device found by a bus search or by its own announcement as a plain HS485Channel and ignored the channel class of the device description. Only a device loaded from its file got its channels through AddChannel(), which creates the class the description names. So channel 0 of a newly learned wired device was no HS485MaintenanceChannel until hs485d was restarted: getValue() of UNREACH, STICKY_UNREACH and CONFIG_PENDING answered false with a warning, and a failed send fired no UNREACH event and left no service message. Rebuild() creates the channels of a device whose type changed the same way. Both now create the channels with AddChannel(), as the load path does, and fall back to a plain channel if that fails. Fixes #166 --- src/hs485d/HS485Device.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/hs485d/HS485Device.cpp b/src/hs485d/HS485Device.cpp index febe10f4..1336ef16 100644 --- a/src/hs485d/HS485Device.cpp +++ b/src/hs485d/HS485Device.cpp @@ -409,9 +409,11 @@ void HS485Device::SetDeviceDescription(HS485DeviceDescription* description, bool int start=ch_desc->GetIndex(); int count=ch_desc->GetCount(); for(int j=0;jSetParent(this, j+start, ch_desc); - if(ch_desc->HasSubdescriptions())ch->GetBehaviour(); + if(!AddChannel(j+start, ch_desc->GetType())){ + HS485Channel* ch=channels[j+start]=CreateChannel(); + ch->SetParent(this, j+start, ch_desc); + } + if(ch_desc->HasSubdescriptions())channels[j+start]->GetBehaviour(); } i++; ch_desc=description->GetChannel(i); @@ -899,9 +901,11 @@ bool HS485Device::Rebuild(const bool enforceConfigRestore /*=false*/, const bool int count=ch_desc->GetCount(); for(int j=0;jSetParent(this, j+start, ch_desc); - if(ch_desc->HasSubdescriptions())ch->GetBehaviour(); + if(!AddChannel(j+start, ch_desc->GetType())){ + HS485Channel* ch=channels[j+start]=CreateChannel(); + ch->SetParent(this, j+start, ch_desc); + } + if(ch_desc->HasSubdescriptions())channels[j+start]->GetBehaviour(); }else{ channels[j+start]->SetDescription(ch_desc); }