From dbe1d2e10c037d84933502732e665217bf55df6b Mon Sep 17 00:00:00 2001 From: Bernhard Trinnes Date: Wed, 13 Jun 2018 23:47:21 +0200 Subject: [PATCH] fixed event connection --- .../devicepluginserialportcommander.cpp | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/serialportcommander/devicepluginserialportcommander.cpp b/serialportcommander/devicepluginserialportcommander.cpp index 6519adbd..0ddec3b2 100644 --- a/serialportcommander/devicepluginserialportcommander.cpp +++ b/serialportcommander/devicepluginserialportcommander.cpp @@ -55,6 +55,7 @@ DeviceManager::DeviceSetupStatus DevicePluginSerialPortCommander::setupDevice(De qCDebug(dcSerialPortCommander()) << "Setup successfully serial port" << interface; SerialPortCommander *serialPortCommander = new SerialPortCommander(serialPort, this); + serialPortCommander->addOutputDevice(device); m_serialPortCommanders.insert(interface, serialPortCommander); } else { @@ -117,24 +118,33 @@ DeviceManager::DeviceError DevicePluginSerialPortCommander::discoverDevices(cons ParamList parameters; if (deviceClassId == serialPortInputDeviceClassId) { + //take the params from the already existing in/output device parameters.append(Param(serialPortInputSerialPortParamTypeId, serialPort->portName())); + parameters.append(Param(serialPortInputBaudRateParamTypeId, serialPort->baudRate())); + parameters.append(Param(serialPortInputDataBitsParamTypeId, serialPort->dataBits())); + parameters.append(Param(serialPortInputFlowControlParamTypeId, serialPort->flowControl())); + parameters.append(Param(serialPortInputStopBitsParamTypeId, serialPort->stopBits())); + parameters.append(Param(serialPortInputParityParamTypeId, serialPort->parity())); } if (deviceClassId == serialPortOutputDeviceClassId) { if (serialPortCommander->hasOutputDevice()){ + //only one output per port is allowed continue; } + //take the params from the already existing input device + parameters.append(Param(serialPortOutputSerialPortParamTypeId, serialPort->portName())); + parameters.append(Param(serialPortOutputBaudRateParamTypeId, serialPort->baudRate())); + parameters.append(Param(serialPortOutputDataBitsParamTypeId, serialPort->dataBits())); + parameters.append(Param(serialPortOutputFlowControlParamTypeId, serialPort->flowControl())); + parameters.append(Param(serialPortOutputStopBitsParamTypeId, serialPort->stopBits())); + parameters.append(Param(serialPortOutputParityParamTypeId, serialPort->parity())); } - parameters.append(Param(serialPortOutputSerialPortParamTypeId, serialPort->portName())); - parameters.append(Param(serialPortOutputBaudRateParamTypeId, serialPort->baudRate())); - parameters.append(Param(serialPortOutputDataBitsParamTypeId, serialPort->dataBits())); - parameters.append(Param(serialPortOutputFlowControlParamTypeId, serialPort->flowControl())); - parameters.append(Param(serialPortOutputStopBitsParamTypeId, serialPort->stopBits())); - parameters.append(Param(serialPortOutputParityParamTypeId, serialPort->parity())); + descriptor.setParams(parameters); deviceDescriptors.append(descriptor); } else { - + //Serial port is not yet used, create now a new one qCDebug(dcSerialPortCommander()) << "Found serial port:" << port.portName(); QString description = port.manufacturer() + " " + port.description(); DeviceDescriptor descriptor(deviceClassId, port.portName(), description);