* @brief Builds and sends the 20-byte initialization frame for the given bitrate. */
| 366 | * @brief Builds and sends the 20-byte initialization frame for the given bitrate. |
| 367 | */ |
| 368 | bool 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 | } |
nothing calls this directly
no test coverage detected