livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
6#pragma once
7
8#include <array>
9#include <cstdint>
10#include <optional>
11#include <string>
12#include <string_view>
13
15#include "livox/mid360/hms.hpp"
16#include "livox/mid360/keys.hpp"
19
20LIVOX_MID360_API_BEGIN
21namespace livox::mid360
22{
23
26{
27 std::uint64_t packets = 0;
28 std::uint64_t points = 0;
29 std::uint64_t frames = 0;
30 std::uint64_t imu_samples = 0;
31 std::uint64_t bad_packets = 0;
32 std::uint64_t dropped_packets = 0;
33 std::uint64_t reordered = 0;
34 std::uint64_t queue_drops = 0;
35 std::uint64_t frame_cnt_fallback = 0;
39 std::uint64_t type_switch_gaps = 0;
40 std::uint64_t last_packet_time_ns = 0;
44 std::uint64_t pushes = 0;
45 std::uint64_t last_push_time_ns = 0;
46 std::uint64_t disconnects = 0;
47 std::uint64_t reconnects = 0;
48 std::int64_t time_offset_ns =
49 0;
50 bool time_offset_valid = false;
54 std::uint64_t log_chunks = 0;
55 std::uint64_t log_bytes = 0;
56 std::uint64_t log_gaps = 0;
57 std::uint64_t log_acks_sent = 0;
58 std::uint64_t bad_log_packets = 0;
59 std::uint64_t last_log_time_ns = 0;
64 std::uint64_t debug_data_packets = 0;
65 std::uint64_t debug_data_bytes = 0;
66 std::uint64_t last_debug_data_time_ns = 0;
68};
69
72{
73 std::uint64_t datagrams = 0;
74 std::uint64_t unknown_source = 0;
75 std::uint64_t log_datagrams = 0;
76 std::uint64_t debug_datagrams = 0;
77};
78
88
90struct Event
91{
93 enum class Kind : std::uint8_t
94 {
95 kStateChanged,
96 kHms,
97 kDiagChanged,
98 kDisconnected,
99 kReconnected,
100 kStats,
101 kFirmwareLogGap,
102 };
104 std::uint64_t time_ns = 0;
106 std::uint32_t attempts = 0;
107 WorkState old_state = WorkState::kIdle;
108 WorkState new_state = WorkState::kIdle;
109 std::array<HmsCode, 8> hms{};
114 std::uint8_t log_file_index = 0;
115 std::uint32_t log_expected = 0;
116 std::uint32_t log_actual = 0;
117};
118
120[[nodiscard]] std::string_view to_string(Event::Kind kind) noexcept;
122[[nodiscard]] std::string_view to_string(DisconnectReason reason) noexcept;
124[[nodiscard]] std::string to_string(const Event & event);
125
128{
130 enum class Kind : std::uint8_t
131 {
132 kSession,
134 kInvalidState,
135 kAlreadyRegistered,
136 kNotOpen,
137 kDisconnected,
138 kDecodeFailed,
139 kIo,
140 };
142 std::optional<SessionError> session;
143 std::optional<Key> key;
144 int errno_value = 0;
145};
146
148[[nodiscard]] std::string_view to_string(DeviceError::Kind kind) noexcept;
150[[nodiscard]] std::string to_string(const DeviceError & err);
151
152} // namespace livox::mid360
153LIVOX_MID360_API_END
Symbol visibility helpers.
HMS (health management system) diagnostic code decoding for the Mid-360.
Key definitions and typed encoders/decoders for the Mid-360 key-value list (section "0x0102 LiDAR Inf...
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
DisconnectReason
Why a Device left the connected state (Event::reason, issue #8).
Definition event.hpp:81
@ kNone
not disconnected (or the event is not a disconnect / reconnect)
Definition event.hpp:82
@ kUser
Device::disconnect().
Definition event.hpp:86
@ kRebootRequested
Device::reboot() was acknowledged.
Definition event.hpp:85
@ kCommandTimeout
a command timed out while the push was already stale
Definition event.hpp:84
@ kPushTimeout
no 0x0102 push for ReconnectOptions::push_timeout
Definition event.hpp:83
WorkState
LiDAR working state (key 0x8006 cur_work_state / 0x001A work_tgt_mode).
Definition protocol.hpp:113
HmsLevel
Abnormal level, byte 0 of an HMS code.
Definition hms.hpp:22
@ kNone
slot unused
Definition hms.hpp:23
std::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
@ kInvalidArgument
rejected before sending; see error_key for the offending key
Definition session.hpp:51
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-com...
Session layer: discovery and synchronous command round-trips with one Mid-360.
Counters of the shared receive side, snapshot via Context::stats().
Definition event.hpp:72
std::uint64_t unknown_source
dropped: source IP not registered by any Device
Definition event.hpp:74
std::uint64_t debug_datagrams
of datagrams, those on the debug data socket (#93)
Definition event.hpp:76
std::uint64_t datagrams
received on all sockets
Definition event.hpp:73
std::uint64_t log_datagrams
of datagrams, those on the firmware log socket
Definition event.hpp:75
Errors of Context / Device. Session-level failures are wrapped, not re-encoded.
Definition event.hpp:128
std::optional< Key > key
kInvalidArgument (out-of-range FOV window) / kDecodeFailed
Definition event.hpp:143
Kind kind
error category
Definition event.hpp:141
std::optional< SessionError > session
kSession only
Definition event.hpp:142
int errno_value
kIo only
Definition event.hpp:144
Kind
Error category; selects the meaningful fields.
Definition event.hpp:131
@ kSession
see session
Definition event.hpp:132
Counters of one Device, snapshot via Device::stats(). Monotonic since open().
Definition event.hpp:26
std::uint64_t last_push_time_ns
host receive time of the last push, 0 = none
Definition event.hpp:45
std::uint64_t packets
data packets accepted (point cloud + IMU)
Definition event.hpp:27
std::int64_t time_offset_ns
kHostOffsetOnce: host - LiDAR, measured once (again after a sync loss)
Definition event.hpp:48
std::uint64_t log_bytes
log payload bytes delivered
Definition event.hpp:55
std::uint64_t bad_log_packets
log-port datagrams that failed to parse
Definition event.hpp:58
std::uint64_t log_acks_sent
pushes that asked for an ACK and got one
Definition event.hpp:57
std::uint64_t frame_cnt_fallback
times frame_cnt mode fell back to the time window
Definition event.hpp:35
std::uint64_t dropped_packets
udp_cnt gaps (per source port)
Definition event.hpp:32
std::uint64_t log_gaps
kFirmwareLogGap events raised
Definition event.hpp:56
std::uint64_t pushes
0x0102 pushes accepted.
Definition event.hpp:44
std::uint64_t imu_samples
ImuSamples delivered.
Definition event.hpp:30
std::uint64_t frames
Frames delivered.
Definition event.hpp:29
std::uint64_t log_chunks
0x0300 pushes delivered (begin / end included)
Definition event.hpp:54
std::uint64_t reordered
udp_cnt went backwards (duplicate / reordered)
Definition event.hpp:33
bool time_offset_valid
time_offset_ns holds a measured offset
Definition event.hpp:50
std::uint64_t last_packet_time_ns
host receive time of the last packet, 0 = none
Definition event.hpp:40
std::uint64_t type_switch_gaps
Point cloud udp_cnt gaps of exactly one packet at a pcl_data_type change.
Definition event.hpp:39
std::uint64_t last_debug_data_time_ns
host receive time of the last one, 0 = none
Definition event.hpp:66
std::uint64_t reconnects
kReconnected events raised
Definition event.hpp:47
std::uint64_t debug_data_packets
datagrams received on the debug data socket
Definition event.hpp:64
std::uint64_t points
samples delivered in Frames
Definition event.hpp:28
std::uint64_t debug_data_bytes
their payload bytes
Definition event.hpp:65
std::uint64_t bad_packets
parse_data_packet failures
Definition event.hpp:31
std::uint64_t queue_drops
reserved for internal queues
Definition event.hpp:34
std::uint64_t last_log_time_ns
host receive time of the last push, 0 = none
Definition event.hpp:59
std::uint64_t disconnects
kDisconnected events raised
Definition event.hpp:46
Key 0x800E, u16 bitfield split into four subsystem levels (issue #55).
Definition keys.hpp:240
One notification. kind selects which fields are meaningful; the rest are default.
Definition event.hpp:91
std::uint32_t log_expected
kFirmwareLogGap: trans_index expected
Definition event.hpp:115
Kind kind
which notification this is
Definition event.hpp:103
Kind
What happened; selects the meaningful fields.
Definition event.hpp:94
@ kStats
periodic stats snapshot (#6)
Definition event.hpp:100
std::uint64_t time_ns
host time of the observation
Definition event.hpp:104
std::uint8_t log_file_index
kFirmwareLogGap
Definition event.hpp:114
WorkState old_state
kStateChanged
Definition event.hpp:107
DiagStatus diag_new
kDiagChanged
Definition event.hpp:112
DeviceStats stats
kStats
Definition event.hpp:113
std::uint32_t attempts
kReconnected: attempts including the successful one
Definition event.hpp:106
DisconnectReason reason
kDisconnected / kReconnected
Definition event.hpp:105
DiagStatus diag_old
kDiagChanged (all normal before the first push)
Definition event.hpp:111
WorkState new_state
kStateChanged
Definition event.hpp:108
HmsLevel hms_level
kHms: highest level among the active slots
Definition event.hpp:110
std::array< HmsCode, 8 > hms
kHms: key 0x8011 slots, inactive ones raw == 0
Definition event.hpp:109
std::uint32_t log_actual
kFirmwareLogGap: trans_index received
Definition event.hpp:116