* @brief Writes @p data to the specified @p deviceId. */
| 593 | * @brief Writes @p data to the specified @p deviceId. |
| 594 | */ |
| 595 | qint64 IO::ConnectionManager::writeDataToDevice(int deviceId, const QByteArray& data) |
| 596 | { |
| 597 | Q_ASSERT(deviceId >= 0); |
| 598 | Q_ASSERT(!data.isEmpty()); |
| 599 | |
| 600 | auto it = m_devices.find(deviceId); |
| 601 | if (it == m_devices.end() || !it->second) |
| 602 | return -1; |
| 603 | |
| 604 | const qint64 bytes = it->second->write(data); |
| 605 | if (bytes > 0) { |
| 606 | auto writtenData = data; |
| 607 | const qint64 boundedBytes = qMin<qint64>(bytes, writtenData.size()); |
| 608 | writtenData.chop(writtenData.length() - boundedBytes); |
| 609 | Console::Handler::instance().displaySentData(deviceId, writtenData); |
| 610 | } |
| 611 | |
| 612 | return bytes; |
| 613 | } |
| 614 | |
| 615 | /** |
| 616 | * @brief Arms reply capture for @p deviceId then writes @p data, atomically on this thread so |
no test coverage detected