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); }