* @brief Builds a FrameConfig for the given @p deviceId from current settings. */
| 1430 | * @brief Builds a FrameConfig for the given @p deviceId from current settings. |
| 1431 | */ |
| 1432 | IO::FrameConfig IO::ConnectionManager::buildFrameConfig(int deviceId) const |
| 1433 | { |
| 1434 | const auto opMode = AppState::instance().operationMode(); |
| 1435 | |
| 1436 | if (opMode == SerialStudio::QuickPlot || opMode == SerialStudio::ConsoleOnly) |
| 1437 | return AppState::instance().frameConfig(); |
| 1438 | |
| 1439 | FrameConfig cfg; |
| 1440 | cfg.operationMode = opMode; |
| 1441 | |
| 1442 | const auto& sources = DataModel::ProjectModel::instance().sources(); |
| 1443 | for (const auto& src : sources) { |
| 1444 | if (src.sourceId != deviceId) |
| 1445 | continue; |
| 1446 | |
| 1447 | QByteArray start, end; |
| 1448 | QString checksum; |
| 1449 | DataModel::read_io_settings(start, end, checksum, DataModel::serialize(src)); |
| 1450 | |
| 1451 | cfg.startSequences = start.isEmpty() ? QList<QByteArray>{} : QList<QByteArray>{start}; |
| 1452 | cfg.finishSequences = end.isEmpty() ? QList<QByteArray>{} : QList<QByteArray>{end}; |
| 1453 | cfg.checksumAlgorithm = checksum; |
| 1454 | cfg.frameDetection = static_cast<SerialStudio::FrameDetection>(src.frameDetection); |
| 1455 | |
| 1456 | if ((cfg.frameDetection == SerialStudio::StartDelimiterOnly |
| 1457 | || cfg.frameDetection == SerialStudio::StartAndEndDelimiter) |
| 1458 | && cfg.startSequences.isEmpty()) [[unlikely]] |
| 1459 | cfg.frameDetection = |
| 1460 | cfg.finishSequences.isEmpty() ? SerialStudio::NoDelimiters : SerialStudio::EndDelimiterOnly; |
| 1461 | |
| 1462 | if (cfg.frameDetection == SerialStudio::EndDelimiterOnly && cfg.finishSequences.isEmpty()) |
| 1463 | [[unlikely]] |
| 1464 | cfg.frameDetection = SerialStudio::NoDelimiters; |
| 1465 | |
| 1466 | return cfg; |
| 1467 | } |
| 1468 | |
| 1469 | cfg.startSequences = {QByteArray("/*")}; |
| 1470 | cfg.finishSequences = {QByteArray("*/")}; |
| 1471 | cfg.checksumAlgorithm = QString(); |
| 1472 | cfg.frameDetection = DataModel::ProjectModel::instance().frameDetection(); |
| 1473 | return cfg; |
| 1474 | } |
| 1475 | |
| 1476 | /** |
| 1477 | * @brief Creates a fresh driver instance for the given bus @p type. |
nothing calls this directly
no test coverage detected