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

Method write

app/src/IO/Drivers/USB.cpp:304–323  ·  view source on GitHub ↗

* @brief Sends @p data to the device via a synchronous bulk OUT transfer. A mutable copy of * @p data is required because libusb takes a non-const buffer and may write into it. */

Source from the content-addressed store, hash-verified

302 * @p data is required because libusb takes a non-const buffer and may write into it.
303 */
304qint64 IO::Drivers::USB::write(const QByteArray& data)
305{
306 Q_ASSERT(!data.isEmpty());
307 Q_ASSERT(m_handle != nullptr);
308
309 if (!isWritable())
310 return -1;
311
312 int transferred = 0;
313 QByteArray mutableData(data);
314 auto* buf = reinterpret_cast<unsigned char*>(mutableData.data());
315
316 const int rc = libusb_bulk_transfer(
317 m_handle, m_activeOutEp, buf, static_cast<int>(data.size()), &transferred, kBulkWriteTimeout);
318 if (rc < 0)
319 return -1;
320
321 Q_EMIT dataSent(data.left(transferred));
322 return static_cast<qint64>(transferred);
323}
324
325//--------------------------------------------------------------------------------------------------
326// Property getters

Callers 15

prelude.jsFile · 0.45
SerialStudio.jsFile · 0.45
Concepts.hFile · 0.45
writeDataToDeviceMethod · 0.45
sendCommandMethod · 0.45
writeFrameMethod · 0.45
sendInitFrameMethod · 0.45
printReportMethod · 0.45
exportMachineInfoMethod · 0.45
onReadmeReplyMethod · 0.45
onScreenshotReplyMethod · 0.45

Calls 3

isEmptyMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected