Changeset View
Changeset View
Standalone View
Standalone View
core/backends/devicelinereader.cpp
Show All 30 Lines | 30 | connect(m_device, SIGNAL(disconnected()), | |||
---|---|---|---|---|---|
31 | this, SIGNAL(disconnected())); | 31 | this, SIGNAL(disconnected())); | ||
32 | } | 32 | } | ||
33 | 33 | | |||
34 | void DeviceLineReader::dataReceived() | 34 | void DeviceLineReader::dataReceived() | ||
35 | { | 35 | { | ||
36 | while(m_device->canReadLine()) { | 36 | while(m_device->canReadLine()) { | ||
37 | const QByteArray line = m_device->readLine(); | 37 | const QByteArray line = m_device->readLine(); | ||
38 | if (line.length() > 1) { | 38 | if (line.length() > 1) { | ||
39 | m_packages.enqueue(line);//we don't want single \n | 39 | m_packets.enqueue(line);//we don't want single \n | ||
40 | } | 40 | } | ||
41 | } | 41 | } | ||
42 | 42 | | |||
43 | //If we still have things to read from the device, call dataReceived again | 43 | //If we still have things to read from the device, call dataReceived again | ||
44 | //We do this manually because we do not trust readyRead to be emitted again | 44 | //We do this manually because we do not trust readyRead to be emitted again | ||
45 | //So we call this method again just in case. | 45 | //So we call this method again just in case. | ||
46 | if (m_device->bytesAvailable() > 0) { | 46 | if (m_device->bytesAvailable() > 0) { | ||
47 | QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection); | 47 | QMetaObject::invokeMethod(this, "dataReceived", Qt::QueuedConnection); | ||
48 | return; | 48 | return; | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | //If we have any packages, tell it to the world. | 51 | //If we have any packets, tell it to the world. | ||
52 | if (!m_packages.isEmpty()) { | 52 | if (!m_packets.isEmpty()) { | ||
53 | Q_EMIT readyRead(); | 53 | Q_EMIT readyRead(); | ||
54 | } | 54 | } | ||
55 | } | 55 | } |