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

Method send

app/src/Console/Handler.cpp:515–558  ·  view source on GitHub ↗

* @brief Sends @a data to the connected device using the current send options. */

Source from the content-addressed store, hash-verified

513 * @brief Sends @a data to the connected device using the current send options.
514 */
515void Console::Handler::send(const QString& data)
516{
517 if (!IO::ConnectionManager::instance().isConnected())
518 return;
519
520 if (!data.isEmpty())
521 addToHistory(data);
522
523 QByteArray bin;
524 if (dataMode() == DataMode::DataHexadecimal)
525 bin = SerialStudio::hexToBytes(data);
526 else
527 bin = SerialStudio::encodeText(SerialStudio::resolveEscapeSequences(data), m_encoding);
528
529 switch (lineEnding()) {
530 case LineEnding::NoLineEnding:
531 break;
532 case LineEnding::NewLine:
533 bin.append('\n');
534 break;
535 case LineEnding::CarriageReturn:
536 bin.append('\r');
537 break;
538 case LineEnding::BothNewLineAndCarriageReturn:
539 bin.append('\r');
540 bin.append('\n');
541 break;
542 }
543
544 const auto checksums = IO::availableChecksums();
545 if (m_checksumMethod >= 0 && m_checksumMethod < checksums.count()) {
546 const auto checksumName = checksums.at(m_checksumMethod);
547 auto checksum = IO::checksum(checksumName, bin);
548 if (!checksum.isEmpty())
549 bin.append(checksum);
550 }
551
552 if (!bin.isEmpty()) {
553 if (m_currentDeviceId >= 0)
554 (void)IO::ConnectionManager::instance().writeDataToDevice(m_currentDeviceId, bin);
555 else
556 (void)IO::ConnectionManager::instance().writeData(bin);
557 }
558}
559
560//--------------------------------------------------------------------------------------------------
561// Settings modification slots

Callers 3

jquery.jsFile · 0.45
test_slowloris_attackFunction · 0.45

Calls 6

isEmptyMethod · 0.80
writeDataToDeviceMethod · 0.80
isConnectedMethod · 0.45
appendMethod · 0.45
countMethod · 0.45
writeDataMethod · 0.45

Tested by 2

test_slowloris_attackFunction · 0.36