69namespace link_direct_detail {
71[[nodiscard]]
constexpr char ascii_upper(
char value)
noexcept {
72 return (value >=
'a' && value <=
'z') ?
static_cast<char>(value - (
'a' -
'A')) : value;
76 return value ==
'\\' || value ==
'/';
88 for (
char ch : text) {
90 if (ch >=
'0' && ch <=
'9') {
92 }
else if (base == 16 && ch >=
'A' && ch <=
'F') {
94 }
else if (base == 16 && ch >=
'a' && ch <=
'f') {
131 if (text.size() <= spec.prefix_length) {
135 bool prefix_match =
true;
136 for (
std::size_t index = 0; index < spec.prefix_length; ++index) {
137 if (
ascii_upper(text[index]) != spec.prefix[index]) {
138 prefix_match =
false;
147 if (!
parse_u32_chars(text.substr(spec.prefix_length), spec.base, number)) {
170 "Link direct device must begin with J");
183 "Link direct device must look like J1\\W100");
188 network_number > 0xFFFFU) {
191 "Link direct network number must be a hexadecimal value in range 0x0000..0xFFFF");
198 "Link direct device must be X, Y, B, W, SB, or SW");
constexpr size_type size() const noexcept
static constexpr size_type npos
constexpr char ascii_upper(char value) noexcept
bool parse_u32_chars(std::string_view text, int base, std::uint32_t &out_value) noexcept
constexpr LinkDirectParseSpec kLinkDirectParseSpecs[]
constexpr bool is_separator(char value) noexcept
bool parse_link_direct_inner_device(std::string_view text, DeviceAddress &out_device) noexcept
Status parse_link_direct_device(std::string_view text, LinkDirectDevice &out_device) noexcept
Parses a Jn\\... link-direct device string such as J1\\W100 or J1\\X10.
DeviceCode
Device-family identifier used by the request codecs.
BitValue
Logical single-bit value used by bit read/write APIs.
constexpr Status make_status(StatusCode code, const char *message, std::uint16_t plc_error_code=0) noexcept
Builds a status value with an optional PLC end code.
constexpr Status ok_status() noexcept
Returns the default success status.
Device code plus numeric address.
DeviceCode code
Device family such as D, M, X, LTN, or LZ.
Parsed Jn\\... link-direct device reference such as J1\\W100.
std::uint16_t network_number
Jn\\... monitor registration payload (0801 + device extension specification).
std::span< const LinkDirectRandomReadItem > items
One Jn\\... block used by native multi-block read.
LinkDirectDevice head_device
Jn\\... native multi-block read request.
std::span< const LinkDirectMultiBlockReadBlock > blocks
One Jn\\... block used by native multi-block write.
std::span< const std::uint16_t > words
std::span< const BitValue > bits
LinkDirectDevice head_device
Jn\\... native multi-block write request.
std::span< const LinkDirectMultiBlockWriteBlock > blocks
One sparse Jn\\... item used by native random-read and monitor registration.
One sparse Jn\\... bit item used by native random bit-write.
One sparse Jn\\... word item used by native random word-write.
Result object returned by most public APIs.
std::size_t prefix_length
Public request, response, configuration, and callback types for the serial MC protocol library.