livox_mid360_core
C++ driver library for the Livox Mid-360 LiDAR
Loading...
Searching...
No Matches
firmware_log.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
6#pragma once
7
8#include <array>
9#include <cstddef>
10#include <cstdint>
11#include <expected>
12#include <span>
13#include <string>
14#include <string_view>
15#include <vector>
16
19
20LIVOX_MID360_API_BEGIN
21namespace livox::mid360
22{
23
25enum class FirmwareLogType : std::uint8_t
26{
29};
30
33{
34 std::uint8_t raw = 0;
36 [[nodiscard]] constexpr bool ack_requested() const noexcept { return (raw & 0x01) != 0; }
38 [[nodiscard]] constexpr bool file_begin() const noexcept { return (raw & 0x02) != 0; }
40 [[nodiscard]] constexpr bool file_end() const noexcept { return (raw & 0x04) != 0; }
41};
42
43inline constexpr std::uint8_t kFirmwareLogFlagAck = 0x01;
44inline constexpr std::uint8_t kFirmwareLogFlagBegin = 0x02;
45inline constexpr std::uint8_t kFirmwareLogFlagEnd = 0x04;
46
48inline constexpr std::size_t kFirmwareLogPushHeaderSize = 16;
50inline constexpr std::size_t kFirmwareLogPushDataMaxSize =
52
59
62{
64 std::uint8_t file_index = 0;
65 std::uint8_t file_num = 0;
67 std::uint32_t timestamp = 0;
68 std::uint16_t rsvd = 0;
69 std::uint32_t trans_index = 0;
70 std::uint16_t data_length = 0;
71};
72
75{
77 std::span<const std::byte> data;
78};
79
82{
83 RetCode ret_code = RetCode::kSuccess;
85 std::uint8_t file_index = 0;
86 std::uint32_t trans_index = 0;
87};
88
90inline constexpr std::size_t kFirmwareLogPushAckSize = 7;
91
96{
98 std::uint64_t host_receive_time_ns = 0;
99 std::span<const std::byte> data;
100};
101
103[[nodiscard]] std::string_view to_string(FirmwareLogType t) noexcept;
105[[nodiscard]] std::string to_string(const FirmwareLogPushHeader & h);
106
108[[nodiscard]] std::array<std::byte, 2> encode_firmware_log_control(
109 const FirmwareLogControlRequest & req) noexcept;
112[[nodiscard]] std::expected<FirmwareLogControlRequest, ParseError> parse_firmware_log_control(
113 std::span<const std::byte> data) noexcept;
114
117[[nodiscard]] std::expected<FirmwareLogPushView, ParseError> parse_firmware_log_push(
118 std::span<const std::byte> data) noexcept;
121[[nodiscard]] std::expected<std::vector<std::byte>, EncodeError> encode_firmware_log_push(
122 const FirmwareLogPushHeader & header, std::span<const std::byte> data);
123
125[[nodiscard]] std::array<std::byte, kFirmwareLogPushAckSize> encode_firmware_log_push_ack(
126 const FirmwareLogPushAck & ack) noexcept;
128[[nodiscard]] std::expected<FirmwareLogPushAck, ParseError> parse_firmware_log_push_ack(
129 std::span<const std::byte> data) noexcept;
130
131} // namespace livox::mid360
132LIVOX_MID360_API_END
Symbol visibility helpers.
The livox_mid360_core library: everything declared by the public headers.
Definition bytes.hpp:14
std::array< std::byte, kFirmwareLogPushAckSize > encode_firmware_log_push_ack(const FirmwareLogPushAck &ack) noexcept
FirmwareLogPushAck payload: {ret_code u8, log_type u8, file_index u8, trans_index u32}...
constexpr std::uint8_t kFirmwareLogFlagBegin
FirmwareLogFlags::file_begin.
Definition firmware_log.hpp:44
constexpr std::size_t kCommandDataMaxSize
Largest command payload that fits a frame.
Definition protocol.hpp:52
constexpr std::uint8_t kFirmwareLogFlagAck
FirmwareLogFlags::ack_requested.
Definition firmware_log.hpp:43
constexpr std::size_t kFirmwareLogPushHeaderSize
Size of the 0x0300 push header in bytes.
Definition firmware_log.hpp:48
std::expected< FirmwareLogPushAck, ParseError > parse_firmware_log_push_ack(std::span< const std::byte > data) noexcept
Inverse of encode_firmware_log_push_ack(); bytes after the seventh are ignored.
FirmwareLogType
log_type of 0x0300 / 0x0301. SDK2 states that only the real-time log is supported.
Definition firmware_log.hpp:26
@ kException
ACKed by 13.18.0244, but no chunk arrived on demand (#11).
Definition firmware_log.hpp:28
@ kRealTime
real-time log
Definition firmware_log.hpp:27
std::array< std::byte, 2 > encode_firmware_log_control(const FirmwareLogControlRequest &req) noexcept
0x0301 payload: {log_type, enable}.
std::expected< FirmwareLogPushView, ParseError > parse_firmware_log_push(std::span< const std::byte > data) noexcept
0x0300 payload: header + data.
RetCode
Result code carried as the first byte of every ACK.
Definition protocol.hpp:93
std::expected< FirmwareLogControlRequest, ParseError > parse_firmware_log_control(std::span< const std::byte > data) noexcept
Inverse of encode_firmware_log_control(); enable is any non-zero byte, extra bytes are ignored.
EncodeError
Why encode_command_frame() or build_command_frame() failed.
Definition protocol.hpp:212
constexpr std::size_t kFirmwareLogPushAckSize
Size of the FirmwareLogPushAck payload in bytes.
Definition firmware_log.hpp:90
constexpr std::uint8_t kFirmwareLogFlagEnd
FirmwareLogFlags::file_end.
Definition firmware_log.hpp:45
std::string_view to_string(Event::Kind kind) noexcept
Name of an event kind, e.g. "state_changed".
std::expected< std::vector< std::byte >, EncodeError > encode_firmware_log_push(const FirmwareLogPushHeader &header, std::span< const std::byte > data)
Serialises a push payload (header + data); nullopt-free: data above the frame limit is an EncodeError...
constexpr std::size_t kFirmwareLogPushDataMaxSize
Largest data part of one 0x0300 push that fits a command frame.
Definition firmware_log.hpp:50
Pure-function protocol layer for the Livox Mid-360: framing, parsing and serialisation of control-com...
What Device hands to a FirmwareLogCallback (receive thread; data is valid only during the callback,...
Definition firmware_log.hpp:96
FirmwareLogPushHeader header
decoded push header
Definition firmware_log.hpp:97
std::span< const std::byte > data
the log bytes of this packet
Definition firmware_log.hpp:99
std::uint64_t host_receive_time_ns
Datagram::recv_time_ns of the push.
Definition firmware_log.hpp:98
0x0301 request: start (enable) or stop collecting log_type.
Definition firmware_log.hpp:55
bool enable
start (true) or stop
Definition firmware_log.hpp:57
FirmwareLogType log_type
log to start or stop
Definition firmware_log.hpp:56
flag bits of a 0x0300 push (SDK2 logger_manager.cpp).
Definition firmware_log.hpp:33
constexpr bool file_begin() const noexcept
First packet of a log file (bit 1).
Definition firmware_log.hpp:38
std::uint8_t raw
the byte as received
Definition firmware_log.hpp:34
constexpr bool ack_requested() const noexcept
The LiDAR expects a FirmwareLogPushAck for this push (bit 0).
Definition firmware_log.hpp:36
constexpr bool file_end() const noexcept
Last packet of a log file (bit 2).
Definition firmware_log.hpp:40
Host → LiDAR answer to a push with ack_requested(), sent as a cmd-type 0x0300 frame.
Definition firmware_log.hpp:82
std::uint32_t trans_index
copied from the push header
Definition firmware_log.hpp:86
RetCode ret_code
result reported to the LiDAR
Definition firmware_log.hpp:83
FirmwareLogType log_type
copied from the push header
Definition firmware_log.hpp:84
std::uint8_t file_index
copied from the push header
Definition firmware_log.hpp:85
0x0300 push header (16 bytes, little-endian) followed by data_length bytes.
Definition firmware_log.hpp:62
std::uint32_t trans_index
+1 per packet inside one file
Definition firmware_log.hpp:69
std::uint16_t rsvd
reserved, carried through unchanged
Definition firmware_log.hpp:68
FirmwareLogFlags flags
ack / begin / end bits
Definition firmware_log.hpp:66
std::uint32_t timestamp
SDK2 never reads it; always 0 on 13.18.0244.
Definition firmware_log.hpp:67
std::uint8_t file_index
which file of the transfer; a begin flag opens a new one
Definition firmware_log.hpp:64
std::uint16_t data_length
number of data bytes after the header
Definition firmware_log.hpp:70
FirmwareLogType log_type
log this push belongs to
Definition firmware_log.hpp:63
std::uint8_t file_num
SDK2 never reads it; 13.18.0244: 0 in the first chunk, then 1.
Definition firmware_log.hpp:65
A validated 0x0300 push: header plus a view over its data.
Definition firmware_log.hpp:75
std::span< const std::byte > data
the data_length bytes after the header
Definition firmware_log.hpp:77
FirmwareLogPushHeader header
decoded header
Definition firmware_log.hpp:76