Merge PR #148: Amperfied: Fix a crash when the Modbus RTU Master is removed
commit
1c698fe8fe
|
|
@ -85,6 +85,13 @@ void ConnectHomeDiscovery::checkNetworkDevice(const NetworkDeviceInfo &networkDe
|
||||||
cleanupConnection(connection);
|
cleanupConnection(connection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connection->version() < 0x100 || connection->version() > 0x2ff) {
|
||||||
|
qCInfo(dcAmperfied()) << "Skipping invalid/unsupported AMPERFIED version" << connection->version();
|
||||||
|
cleanupConnection(connection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Result result;
|
Result result;
|
||||||
result.firmwareVersion = connection->version();
|
result.firmwareVersion = connection->version();
|
||||||
result.networkDeviceInfo = networkDeviceInfo;
|
result.networkDeviceInfo = networkDeviceInfo;
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,6 @@ IntegrationPluginAmperfied::IntegrationPluginAmperfied()
|
||||||
|
|
||||||
void IntegrationPluginAmperfied::discoverThings(ThingDiscoveryInfo *info)
|
void IntegrationPluginAmperfied::discoverThings(ThingDiscoveryInfo *info)
|
||||||
{
|
{
|
||||||
hardwareManager()->modbusRtuResource();
|
|
||||||
|
|
||||||
if (info->thingClassId() == energyControlThingClassId) {
|
if (info->thingClassId() == energyControlThingClassId) {
|
||||||
EnergyControlDiscovery *discovery = new EnergyControlDiscovery(hardwareManager()->modbusRtuResource(), info);
|
EnergyControlDiscovery *discovery = new EnergyControlDiscovery(hardwareManager()->modbusRtuResource(), info);
|
||||||
|
|
||||||
|
|
@ -270,6 +268,11 @@ void IntegrationPluginAmperfied::setupRtuConnection(ThingSetupInfo *info)
|
||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
ModbusRtuMaster *master = hardwareManager()->modbusRtuResource()->getModbusRtuMaster(thing->paramValue(energyControlThingRtuMasterParamTypeId).toUuid());
|
ModbusRtuMaster *master = hardwareManager()->modbusRtuResource()->getModbusRtuMaster(thing->paramValue(energyControlThingRtuMasterParamTypeId).toUuid());
|
||||||
|
if (!master) {
|
||||||
|
qCWarning(dcAmperfied()) << "The Modbus Master is not available any more.";
|
||||||
|
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("The modbus RTU connection is not available."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
quint16 slaveId = thing->paramValue(energyControlThingSlaveIdParamTypeId).toUInt();
|
quint16 slaveId = thing->paramValue(energyControlThingSlaveIdParamTypeId).toUInt();
|
||||||
AmperfiedModbusRtuConnection *connection = new AmperfiedModbusRtuConnection(master, slaveId, thing);
|
AmperfiedModbusRtuConnection *connection = new AmperfiedModbusRtuConnection(master, slaveId, thing);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue