33 #include <QtCore/QtPlugin>
34 #include <QMainWindow>
37 #include <QFontMetrics>
41 , m_deviceOpened(false)
49 connect(&
periodicTimer, &QTimer::timeout,
this, &SerialConnection::periodic);
63 return s1.portName() < s2.portName();
66 void SerialConnection::periodic()
84 std::sort(ports.begin(), ports.end(),
sortPorts);
86 foreach (QSerialPortInfo port, ports) {
88 foreach (IDevice *device, m_available_device_list) {
89 if (device->getName() == port.portName()) {
97 if (port.description().length()) {
98 QFontMetrics font((QFont()));
99 disp.append(font.elidedText(port.description(), Qt::ElideRight, 150));
101 disp.append(port.portName());
104 m_available_device_list.append(d);
109 foreach (IDevice *device, m_available_device_list) {
111 foreach (QSerialPortInfo port, ports) {
112 if (device->getName() == port.portName()) {
118 m_available_device_list.removeOne(device);
119 device->deleteLater();
130 return m_available_device_list;
139 foreach (QSerialPortInfo port, ports) {
140 if (port.portName() == deviceName->getName()) {
143 serialHandle =
new QSerialPort(port);
144 if (serialHandle->open(QIODevice::ReadWrite)) {
145 if (serialHandle->setBaudRate(m_config->
speed().toInt())
146 && serialHandle->setDataBits(QSerialPort::Data8)
147 && serialHandle->setParity(QSerialPort::NoParity)
148 && serialHandle->setStopBits(QSerialPort::OneStop)
149 && serialHandle->setFlowControl(QSerialPort::NoFlowControl)) {
161 Q_UNUSED(deviceName);
164 serialHandle->deleteLater();
172 return QString(
"Serial port");
177 return QString(
"Serial");
185 enablePolling =
false;
193 enablePolling =
true;
196 SerialPlugin::SerialPlugin()
200 SerialPlugin::~SerialPlugin()
205 void SerialPlugin::extensionsInitialized()
210 bool SerialPlugin::initialize(
const QStringList &arguments, QString *errorString)
213 Q_UNUSED(errorString);
void availableDevChanged(IConnection *)
void addObject(QObject *obj)
virtual ~SerialConnection()
virtual QString shortName()
void setName(QString theName)
virtual void closeDevice(const QString &deviceName)
bool sortPorts(const QSerialPortInfo &s1, const QSerialPortInfo &s2)
SerialPluginOptionsPage * Optionspage() const
void onEnumerationChanged()
virtual QIODevice * openDevice(Core::IDevice *deviceName)
void setDisplayName(QString dn)
virtual QList< Core::IDevice * > availableDevices()
void removeObject(QObject *obj)
virtual void suspendPolling()
virtual QString connectionName()
void addAutoReleasedObject(QObject *obj)
virtual void resumePolling()
end for as it was simply a dummy placeholder disp(['Unknown object ID:0x'dec2hex(unknownObjIDList(i, 1), 8) 'appeared 'int2str(unknownObjIDList(i, 2)) 'times.'])