Motion Master 6.0.0-alpha.111
Next-generation motion control software
Loading...
Searching...
No Matches
foe_error_codes.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <array>
5#include <cstdint>
6#include <nlohmann/json_fwd.hpp>
7#include <string_view>
8
9namespace mm::comm {
10
13 uint32_t code = 0;
14 std::string_view name;
15 std::string_view description;
16};
17
25void to_json(nlohmann::json& j, const FoeErrorCode& e);
26
31inline constexpr auto kFoeErrorCodes = std::to_array<FoeErrorCode>({
32 {0x00000000, "Undefined", "Unspecified or vendor-specific FoE error"},
33 {0x00008000, "Not defined", "General FoE error with no further classification"},
34 {0x00008001, "Not found", "The requested file was not found on the slave"},
35 {0x00008002, "Access denied", "Access to the requested file is denied"},
36 {0x00008003, "Disk full", "The slave has insufficient storage to complete the transfer"},
37 {0x00008004, "Illegal", "Illegal FoE operation"},
38 {0x00008005, "Packet number wrong",
39 "Received a data packet with an unexpected sequence number"}, // NOLINT
40 {0x00008006, "Already exists", "The file already exists on the slave"},
41 {0x00008007, "No user", "No user is logged in; authentication required"},
42 {0x00008008, "Bootstrap only", "This operation is only available in Bootstrap state"},
43 {0x00008009, "Not Bootstrap", "This operation is not available in Bootstrap state"},
44 {0x0000800A, "No rights", "Insufficient rights to perform the requested operation"},
45 {0x0000800B, "Program error", "A program error occurred on the slave"},
46});
47
50constexpr std::string_view foeErrorCodeName(uint32_t code) {
51 const auto it = std::find_if(kFoeErrorCodes.begin(), kFoeErrorCodes.end(),
52 [code](const FoeErrorCode& e) { return e.code == code; });
53 return it != kFoeErrorCodes.end() ? it->name : std::string_view{};
54}
55
56} // namespace mm::comm
Definition al_status_codes.cc:5
void to_json(nlohmann::json &j, const AlStatusCode &c)
Serialises an AlStatusCode to JSON.
Definition al_status_codes.cc:7
constexpr std::string_view foeErrorCodeName(uint32_t code)
Returns the name of code, or an empty view if code is not a known FoE error code (vendor-specific,...
Definition foe_error_codes.h:50
constexpr auto kFoeErrorCodes
Catalogue of FoE error codes defined in ETG.1000.6 ยง5.8.5, Table 93.
Definition foe_error_codes.h:31
uint32_t code
Definition soem_fieldbus_driver.cc:1253
Metadata for a single FoE error code entry.
Definition foe_error_codes.h:12
std::string_view description
Full description of the error condition.
Definition foe_error_codes.h:15
uint32_t code
32-bit FoE error code as sent in the FoE ERROR packet.
Definition foe_error_codes.h:13
std::string_view name
Short human-readable name.
Definition foe_error_codes.h:14