f87e5aad40
Send 0x1F6 risk updates through a bounded latest-result worker on CH0 and disable CH1 initialization, reception, transmission and live display. Preserve the four actual-position bytes from 0x391 and recorded-session compatibility. Include regression coverage, Orin camera/TensorRT/CAN validation, and the verified standalone binary with refreshed checksums.
37 lines
1.5 KiB
C++
37 lines
1.5 KiB
C++
#pragma once
|
|
#include "can_types.hpp"
|
|
#include <memory>
|
|
#include <string_view>
|
|
|
|
namespace cms {
|
|
// One lifecycle per instance; only one owner per device index in a process.
|
|
// start() must run after StopSignals so the receiver inherits its signal mask.
|
|
// Missing hardware is reported by snapshot(), and does not stop inference.
|
|
class CanBus {
|
|
public:
|
|
explicit CanBus(CanConfig config);
|
|
~CanBus();
|
|
CanBus(CanBus const&)=delete;
|
|
CanBus& operator=(CanBus const&)=delete;
|
|
void start();
|
|
void requestStop() noexcept;
|
|
void join() noexcept;
|
|
CanSnapshot snapshot() const;
|
|
// Thread-safe on-demand data-frame send; invalid frames throw, SDK failure
|
|
// returns false. Never generates periodic or inference-triggered messages.
|
|
bool send(CanFrame const& frame);
|
|
// Send one standard 8-byte 0x1F6 frame on CH0. Both nibbles of
|
|
// data[0] contain 0 for "clear", 1 for every other level (including
|
|
// unavailable): 0x00 or 0x11. Bytes 1-7 are zero. Returns {CH0 result, false};
|
|
// the second slot is retained for API compatibility, CH1 is never sent.
|
|
std::array<bool,2> sendRisk(std::string_view riskLevel);
|
|
// Nonblocking live-inference path. Keeps at most one pending risk result;
|
|
// a newer result replaces one waiting behind a slow SDK send. Returns
|
|
// queue acceptance, not delivery. No timer or retransmission of old risk.
|
|
bool queueRisk(std::string_view riskLevel);
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
}
|