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

Method sendInitFrame

app/src/IO/Drivers/SeeedCanBackend.cpp:368–390  ·  view source on GitHub ↗

* @brief Builds and sends the 20-byte initialization frame for the given bitrate. */

Source from the content-addressed store, hash-verified

366 * @brief Builds and sends the 20-byte initialization frame for the given bitrate.
367 */
368bool IO::Drivers::SeeedCanBackend::sendInitFrame(quint32 bitrate)
369{
370 QByteArray frame(20, 0);
371 frame[0] = static_cast<char>(kFrameStart);
372 frame[1] = static_cast<char>(kFrameEnd);
373 frame[2] = 0x12;
374 frame[3] = static_cast<char>(seeedBitrateCode(bitrate));
375 frame[4] = 0x01;
376 frame[13] = 0x00;
377 frame[14] = 0x01;
378
379 int checksum = 0;
380 for (int i = 2; i <= 18; ++i)
381 checksum += static_cast<std::uint8_t>(frame.at(i));
382
383 frame[19] = static_cast<char>(checksum & 0xff);
384
385 if (m_port->write(frame) != frame.size())
386 return false;
387
388 m_port->flush();
389 return true;
390}

Callers

nothing calls this directly

Calls 4

seeedBitrateCodeFunction · 0.85
writeMethod · 0.45
sizeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected