livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
hms.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
9#pragma once
10
11#include <cstdint>
12#include <string_view>
13
15
16LIVOX_MID360_API_BEGIN
17namespace livox::mid360
18{
19
21enum class HmsLevel : std::uint8_t
22{
23 kNone = 0,
24 kInfo = 1,
25 kWarning = 2,
26 kError = 3,
27 kFatal = 4,
28};
29
31struct HmsCode
32{
33 std::uint16_t abnormal_id;
35 std::uint8_t reserved;
36 std::uint32_t raw;
37
39 [[nodiscard]] constexpr bool active() const noexcept { return raw != 0; }
40};
41
43[[nodiscard]] constexpr HmsCode decode_hms(std::uint32_t raw) noexcept
44{
45 return {
46 static_cast<std::uint16_t>(raw >> 16), static_cast<HmsLevel>(raw & 0xFFu),
47 static_cast<std::uint8_t>((raw >> 8) & 0xFFu), raw};
48}
49
51[[nodiscard]] std::string_view to_string(HmsLevel l) noexcept;
52
54[[nodiscard]] std::string_view hms_description(std::uint16_t abnormal_id) noexcept;
55
57[[nodiscard]] std::string_view hms_suggestion(std::uint16_t abnormal_id) noexcept;
58
59} // namespace livox::mid360
60LIVOX_MID360_API_END
Symbol visibility helpers.
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
@ kNone
not disconnected (or the event is not a disconnect / reconnect)
Definition event.hpp:82
std::string_view hms_suggestion(std::uint16_t abnormal_id) noexcept
Suggested action from the official table, or "" if unknown.
constexpr HmsCode decode_hms(std::uint32_t raw) noexcept
Splits a raw HMS code into its fields.
Definition hms.hpp:43
std::string_view hms_description(std::uint16_t abnormal_id) noexcept
Human-readable description for an abnormal ID from the official table, or "" if unknown.
HmsLevel
Abnormal level, byte 0 of an HMS code.
Definition hms.hpp:22
std::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
One decoded HMS code (one of the eight uint32 slots of key 0x8011).
Definition hms.hpp:32
std::uint32_t raw
the undecoded code
Definition hms.hpp:36
std::uint16_t abnormal_id
byte 3-2; look up with hms_description() / hms_suggestion()
Definition hms.hpp:33
constexpr bool active() const noexcept
False for an unused slot (raw code 0).
Definition hms.hpp:39
std::uint8_t reserved
byte 1
Definition hms.hpp:35
HmsLevel level
byte 0
Definition hms.hpp:34