26#ifndef MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES
27#define MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES 4096U
30#ifndef MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES
31#define MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES 4096U
34#ifndef MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES
35#define MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES 3500U
38#ifndef MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS
39#define MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS 960U
42#ifndef MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII
43#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII 7904U
46#ifndef MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY
47#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY 3584U
50#ifndef MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS
51#define MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS 192U
54#ifndef MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT
55#define MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT 120U
58#ifndef MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS
59#define MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS 192U
62#ifndef MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES
63#define MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES 960U
66#ifndef MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS
67#define MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS 1
70#ifndef MCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDS
71#define MCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDS 1
74#ifndef MCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS
75#define MCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS 1
78#ifndef MCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDS
79#define MCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDS 1
82#ifndef MCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDS
83#define MCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDS 1
86#ifndef MCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDS
87#define MCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDS 1
90#ifndef MCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS
91#define MCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS 1
94#ifndef MCPROTOCOL_SERIAL_ENABLE_ASCII_MODE
95#define MCPROTOCOL_SERIAL_ENABLE_ASCII_MODE 1
98#ifndef MCPROTOCOL_SERIAL_ENABLE_BINARY_MODE
99#define MCPROTOCOL_SERIAL_ENABLE_BINARY_MODE 1
102#ifndef MCPROTOCOL_SERIAL_ENABLE_FRAME_C4
103#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C4 1
106#ifndef MCPROTOCOL_SERIAL_ENABLE_FRAME_C3
107#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C3 1
110#ifndef MCPROTOCOL_SERIAL_ENABLE_FRAME_C2
111#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C2 1
114#ifndef MCPROTOCOL_SERIAL_ENABLE_FRAME_C1
115#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C1 1
118#ifndef MCPROTOCOL_SERIAL_ENABLE_FRAME_E1
119#define MCPROTOCOL_SERIAL_ENABLE_FRAME_E1 1
RemoteOperationMode
Conflict-handling mode for remote RUN / PAUSE.
ResponseType
Decoded PLC response class before command-specific parsing.
@ SuccessData
Successful response carrying payload bytes.
@ SuccessNoData
Successful response carrying no payload bytes.
DeviceCode
Device-family identifier used by the request codecs.
RouteKind
Route layout inside the request header.
@ MultidropStation
Multidrop route where the destination station number is encoded in the frame.
@ HostStation
Host-station route with fixed station=0, network=0, and pc=FF.
FrameKind
MC protocol frame family used on the serial link.
@ C1
Legacy ASCII serial frame with its own command naming and routing rules.
@ C3
Shorter ASCII serial frame that reuses the C4 payload codec.
@ E1
Legacy frame family used by chapter-18 style command layouts.
@ C4
Chapter-8/10/11/13 oriented serial frame with the fullest feature coverage in this repository.
@ C2
Smallest ASCII serial frame supported by this repository.
GlobalSignalTarget
C24 global-signal selector used by command 1618.
BitValue
Logical single-bit value used by bit read/write APIs.
constexpr std::size_t kMaxUserFrameRegistrationBytes
constexpr std::size_t kMaxMonitorItems
constexpr std::size_t kMaxRandomAccessItems
constexpr std::size_t kMaxRequestFrameBytes
constexpr std::size_t kMaxRequestDataBytes
CodeMode
Request/response payload encoding.
@ Binary
Compact binary command data and response data.
@ Ascii
Text-encoded command data and response data.
AsciiFormat
ASCII formatting variant for C4 / C3 / C2 serial frames.
@ Format1
ENQ/STX/ETX layout without CR/LF.
@ Format4
CR/LF terminated layout often used by host-facing bring-up tools.
@ Format3
STX-only layout commonly used on serial MC links.
@ Format2
Format1 plus a 1-byte block number used for request/response pairing on 2C/3C/4C.
constexpr std::size_t kMaxBatchBitPointsAscii
constexpr std::size_t kMaxBatchBitPointsBinary
PlcSeries
PLC family selection used for subcommand and device-layout differences.
constexpr std::size_t kMaxLoopbackBytes
constexpr std::size_t kCpuModelNameLength
constexpr std::size_t kMaxMultiBlockCount
constexpr std::size_t kMaxBatchWordPoints
constexpr std::size_t kMaxResponseFrameBytes
void(*)(void *user, Status status) CompletionHandler
Completion callback used by the async client.
RemoteRunClearMode
Clear scope applied during remote RUN initialization.
Contiguous bit-read request (0401 bit path).
std::uint16_t points
Number of bit points to read starting at head_device.
DeviceAddress head_device
First bit device in the contiguous range.
std::uint16_t points
Number of points to read starting at head_device.
DeviceAddress head_device
First device in the contiguous range.
Contiguous bit-write request (1401 bit path).
DeviceAddress head_device
First bit device in the contiguous write range.
std::span< const BitValue > bits
Caller-owned bit data to write starting at head_device.
Contiguous word-write request (1401).
std::span< const std::uint16_t > words
Caller-owned word data to write starting at head_device.
DeviceAddress head_device
First device in the contiguous write range.
std::uint16_t model_code
Raw model code returned by the target.
std::array< char, kCpuModelNameLength+1 > model_name
Null-terminated CPU model name with trailing spaces already trimmed by the parser.
Device code plus numeric address.
std::uint32_t number
Numeric index inside the selected device family.
DeviceCode code
Device family such as D, M, X, LTN, or LZ.
Extended file-register address using block number plus R word number.
std::uint16_t block_number
Extended file-register block number.
std::uint16_t word_number
Word number inside the selected block.
std::uint16_t points
Number of words to read from the file-register range.
ExtendedFileRegisterAddress head_device
First block-addressed file-register word to read.
Extended file-register batch write (EW on 1C ACPU-common, chapter-18 block path on 1E).
ExtendedFileRegisterAddress head_device
First block-addressed file-register word to write.
std::span< const std::uint16_t > words
Caller-owned word data to write starting at head_device.
Direct extended file-register batch read (NR on 1C QnA-common, chapter-18 direct path on 1E).
std::uint16_t points
Number of words to read from the direct file-register range.
std::uint32_t head_device_number
NR/NW direct address on 1C or the chapter-18 direct R address on 1E.
Direct extended file-register batch write (NW on 1C QnA-common, chapter-18 direct path on 1E).
std::uint32_t head_device_number
NR/NW direct address on 1C or the chapter-18 direct R address on 1E.
std::span< const std::uint16_t > words
Caller-owned word data to write starting at head_device_number.
Extended file-register monitor registration (EM on 1C, chapter-18 on 1E).
std::span< const ExtendedFileRegisterAddress > items
Sparse list of block-addressed file-register items to register for monitoring.
One item inside extended file-register random write (ET on 1C, chapter-18 on 1E).
std::uint16_t value
One word written to device.
ExtendedFileRegisterAddress device
Target extended file-register address.
C24 global-signal ON/OFF request (1618).
GlobalSignalTarget target
Which global signal destination should be controlled.
bool turn_on
true for ON, false for OFF.
std::uint8_t station_no
Station number encoded in the 1618 specification word.
std::uint32_t start_address
Starting host-buffer word address.
std::uint16_t word_length
Number of words to read.
Host-buffer write request (1613).
std::uint32_t start_address
Starting host-buffer word address.
std::span< const std::uint16_t > words
Caller-owned words written sequentially from start_address.
Module-buffer byte read request (0601 helper path).
std::uint16_t bytes
Number of bytes to read.
std::uint32_t start_address
Starting module-buffer byte address.
std::uint16_t module_number
Module number used by the addressed special-function module.
Module-buffer byte write request (1601 helper path).
std::uint16_t module_number
Module number used by the addressed special-function module.
std::span< const std::byte > bytes
Caller-owned raw bytes written starting at start_address.
std::uint32_t start_address
Starting module-buffer byte address.
std::span< const RandomReadItem > items
Sparse list of word/dword items to register for a later 0802 read.
Parsed layout description for one block returned by parse_multi_block_read_response().
std::uint16_t points
Point count copied from the original request.
DeviceAddress head_device
Block head device copied from the original request.
bool bit_block
Block kind copied from the original request.
std::uint16_t data_offset
Offset into the aggregate output storage returned by the parser.
std::uint16_t data_count
Number of entries contributed by this block to the aggregate output storage.
One block inside native multi-block read (0406).
bool bit_block
true for bit blocks, false for word blocks.
DeviceAddress head_device
First device in this contiguous block.
std::uint16_t points
Number of points in this block.
Native multi-block read request composed of multiple contiguous blocks.
std::span< const MultiBlockReadBlock > blocks
Ordered block list encoded into the native multi-block read request.
One block inside native multi-block write (1406).
std::uint16_t points
Point count for this block.
std::span< const std::uint16_t > words
Caller-owned word data for word blocks.
bool bit_block
true when bits is used, false when words is used.
std::span< const BitValue > bits
Caller-owned bit data for bit blocks.
DeviceAddress head_device
First device in this contiguous block.
Native multi-block write request composed of multiple contiguous blocks.
std::span< const MultiBlockWriteBlock > blocks
Ordered block list encoded into the native multi-block write request.
Top-level protocol configuration shared by codecs and client requests.
bool sum_check_enabled
Enables or disables the ASCII/binary sum-check where that frame family supports it.
AsciiFormat ascii_format
Selected ASCII framing flavor when code_mode == CodeMode::Ascii.
RouteConfig route
Route header fields used for every encoded request.
PlcSeries target_series
PLC family used for device and subcommand differences.
CodeMode code_mode
Selected payload encoding inside the frame.
FrameKind frame_kind
Selected serial frame family.
TimeoutConfig timeout
Request timeout policy used by the async client and stream decoder.
std::uint8_t ascii_block_number
bool double_word
true when the item should be encoded as a double-word device access.
DeviceAddress device
Target device address for this sparse item.
Native random-read request made of sparse word/dword items.
std::span< const RandomReadItem > items
Sparse word/dword items encoded in the native random-read request.
One bit item inside native random write (1402 bit path).
DeviceAddress device
Target bit device address for the sparse write.
BitValue value
Bit value written to device.
One word or double-word item inside native random write (1402 word path).
bool double_word
true when the target is encoded as a double-word write item.
std::uint32_t value
One word or double-word value to write.
DeviceAddress device
Target device address for the sparse write.
Route header fields for serial MC requests.
std::uint16_t request_destination_module_io_no
Destination I/O number for the target CPU/module in 3C/4C routing.
std::uint8_t network_no
Network number used by routed 3C/4C requests.
std::uint8_t self_station_no
Self-station number used when self_station_enabled is true.
RouteKind kind
Route interpretation used by the selected frame family.
bool self_station_enabled
Enables self-station routing on frame families that support it.
std::uint8_t request_destination_module_station_no
Destination station number for the target CPU/module in 3C/4C routing.
std::uint8_t pc_no
PLC number field used by 3C/4C and legacy frame families.
std::uint8_t station_no
Target station number on multidrop serial links.
Optional RS-485 callbacks used by the async client around TX start/end.
void * user
Opaque user pointer passed back to both callbacks.
void(* on_tx_end)(void *user)
Optional callback fired after TX completion or after cleanup on failure/cancel.
void(* on_tx_begin)(void *user)
Optional callback fired immediately before the client expects TX to start.
Result object returned by most public APIs.
Timeout settings used by the frame decoder and async client.
std::uint32_t response_timeout_ms
Maximum wait after TX completion before the request is treated as timed out.
std::uint32_t inter_byte_timeout_ms
Maximum allowed idle gap between RX bytes once a response has started.
User-frame registration-data delete request (1610, subcommand 0001).
std::uint16_t frame_no
User-frame number to clear.
std::uint16_t frame_no
User-frame number to read, typically in the documented 0x0000..0x03FF or 0x8001..0x801F ranges.
User-frame registration-data payload returned by 0610.
std::uint16_t registration_data_bytes
Number of valid bytes in registration_data.
std::array< std::byte, kMaxUserFrameRegistrationBytes > registration_data
Raw user-frame registration bytes as returned by the target.
std::uint16_t frame_bytes
Optional frame-byte count returned by the target for the registered frame data.
User-frame registration-data write request (1610, subcommand 0000).
std::span< const std::byte > registration_data
Raw user-frame registration bytes to store.
std::uint16_t frame_no
User-frame number to overwrite.
std::uint16_t frame_bytes
Frame-byte count encoded into the 1610 payload.
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY
#define MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT
#define MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS
#define MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES
#define MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS
#define MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII
#define MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES
#define MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS
#define MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES