MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / writeDataToDevice

Method writeDataToDevice

app/src/IO/ConnectionManager.cpp:595–613  ·  view source on GitHub ↗

* @brief Writes @p data to the specified @p deviceId. */

Source from the content-addressed store, hash-verified

593 * @brief Writes @p data to the specified @p deviceId.
594 */
595qint64 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

Callers 6

sendMethod · 0.80
activateActionMethod · 0.80
keyPressEventMethod · 0.80
sendValueMethod · 0.80
onConnectedChangedMethod · 0.80
performDeviceWriteFunction · 0.80

Calls 6

isEmptyMethod · 0.80
findMethod · 0.80
lengthMethod · 0.80
displaySentDataMethod · 0.80
writeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected