#pragma once #include #include #include #include namespace cms { inline constexpr unsigned canReceiveChannel=0; inline constexpr unsigned canTransmitChannel=1; inline constexpr unsigned canHardwareChannelCount=2; inline constexpr unsigned liveCanChannelCount=1; // Only CH0 contributes live receive data. struct CanConfig { bool enabled{true}; int device_index{0}; int timeout_ms{1000}; bool termination{true}; }; struct CanDoorSignals { // Raw unsigned bytes: left front, right front, left rear, right rear. // No scale/unit is specified in the reference protocol. std::array positions{{-1,-1,-1,-1}}; bool valid{},fd{},extended{}; std::uint64_t received{},received_monotonic_ns{}; std::uint32_t device_timestamp_us{}; double age_ms{-1}; }; struct CanSnapshot { std::string source{"live"},status{"DISABLED"}; // Keep two slots for existing recorded sessions; live CH1 stays unset. std::array channels; std::uint64_t received{},transmitted{},transmit_errors{},receive_errors{}; }; struct CanFrame { int channel{}; std::uint32_t id{}; bool fd{},extended{},bitrate_switch{}; std::vector data; }; }