MC Protocol Serial C++ 0.2.3
MC protocol serial library for MCU-oriented environments
Loading...
Searching...
No Matches
mcprotocol::serial Namespace Reference

Namespaces

namespace  CommandCodec
 Command-payload codec helpers below the frame layer.
 
namespace  detail
 
namespace  highlevel
 
 

Classes

struct  BatchReadBitsRequest
 Contiguous bit-read request (0401 bit path). More...
 
struct  BatchReadWordsRequest
 
struct  BatchWriteBitsRequest
 Contiguous bit-write request (1401 bit path). More...
 
struct  BatchWriteWordsRequest
 Contiguous word-write request (1401). More...
 
struct  CpuModelInfo
 
struct  DecodeResult
 Result returned by FrameCodec::decode_response(). More...
 
struct  DeviceAddress
 Device code plus numeric address. More...
 
struct  ExtendedFileRegisterAddress
 Extended file-register address using block number plus R word number. More...
 
struct  ExtendedFileRegisterBatchReadWordsRequest
 
struct  ExtendedFileRegisterBatchWriteWordsRequest
 Extended file-register batch write (EW on 1C ACPU-common, chapter-18 block path on 1E). More...
 
struct  ExtendedFileRegisterDirectBatchReadWordsRequest
 Direct extended file-register batch read (NR on 1C QnA-common, chapter-18 direct path on 1E). More...
 
struct  ExtendedFileRegisterDirectBatchWriteWordsRequest
 Direct extended file-register batch write (NW on 1C QnA-common, chapter-18 direct path on 1E). More...
 
struct  ExtendedFileRegisterMonitorRegistration
 Extended file-register monitor registration (EM on 1C, chapter-18 on 1E). More...
 
struct  ExtendedFileRegisterRandomWriteWordItem
 One item inside extended file-register random write (ET on 1C, chapter-18 on 1E). More...
 
class  FrameCodec
 Frame-level encode/decode helper for complete serial MC frames. More...
 
struct  GlobalSignalControlRequest
 C24 global-signal ON/OFF request (1618). More...
 
struct  HostBufferReadRequest
 
struct  HostBufferWriteRequest
 Host-buffer write request (1613). More...
 
struct  LinkDirectDevice
 Parsed Jn\\... link-direct device reference such as J1\\W100. More...
 
struct  LinkDirectMonitorRegistration
 Jn\\... monitor registration payload (0801 + device extension specification). More...
 
struct  LinkDirectMultiBlockReadBlock
 One Jn\\... block used by native multi-block read. More...
 
struct  LinkDirectMultiBlockReadRequest
 Jn\\... native multi-block read request. More...
 
struct  LinkDirectMultiBlockWriteBlock
 One Jn\\... block used by native multi-block write. More...
 
struct  LinkDirectMultiBlockWriteRequest
 Jn\\... native multi-block write request. More...
 
struct  LinkDirectRandomReadItem
 One sparse Jn\\... item used by native random-read and monitor registration. More...
 
struct  LinkDirectRandomWriteBitItem
 One sparse Jn\\... bit item used by native random bit-write. More...
 
struct  LinkDirectRandomWriteWordItem
 One sparse Jn\\... word item used by native random word-write. More...
 
class  MelsecSerialClient
 Asynchronous MC protocol client for UART / serial integrations. More...
 
struct  ModuleBufferReadRequest
 Module-buffer byte read request (0601 helper path). More...
 
struct  ModuleBufferWriteRequest
 Module-buffer byte write request (1601 helper path). More...
 
struct  MonitorRegistration
 
struct  MultiBlockReadBlock
 One block inside native multi-block read (0406). More...
 
struct  MultiBlockReadBlockResult
 Parsed layout description for one block returned by parse_multi_block_read_response(). More...
 
struct  MultiBlockReadRequest
 Native multi-block read request composed of multiple contiguous blocks. More...
 
struct  MultiBlockWriteBlock
 One block inside native multi-block write (1406). More...
 
struct  MultiBlockWriteRequest
 Native multi-block write request composed of multiple contiguous blocks. More...
 
struct  PosixSerialConfig
 Host-side serial-port configuration used by PosixSerialPort. More...
 
class  PosixSerialPort
 Minimal blocking host-side serial-port wrapper used by the CLI tools. More...
 
class  PosixSyncClient
 Host-side synchronous convenience wrapper built on PosixSerialPort and MelsecSerialClient. More...
 
struct  ProtocolConfig
 Top-level protocol configuration shared by codecs and client requests. More...
 
struct  QualifiedBufferWordDevice
 Parsed U...\\G... or U...\\HG... qualified word device. More...
 
struct  RandomReadItem
 
struct  RandomReadRequest
 Native random-read request made of sparse word/dword items. More...
 
struct  RandomWriteBitItem
 One bit item inside native random write (1402 bit path). More...
 
struct  RandomWriteWordItem
 One word or double-word item inside native random write (1402 word path). More...
 
struct  RawResponseFrame
 Raw decoded response frame before command-specific parsing. More...
 
struct  RouteConfig
 Route header fields for serial MC requests. More...
 
struct  Rs485Hooks
 Optional RS-485 callbacks used by the async client around TX start/end. More...
 
struct  Status
 Result object returned by most public APIs. More...
 
struct  TimeoutConfig
 Timeout settings used by the frame decoder and async client. More...
 
struct  UserFrameDeleteRequest
 User-frame registration-data delete request (1610, subcommand 0001). More...
 
struct  UserFrameReadRequest
 
struct  UserFrameRegistrationData
 User-frame registration-data payload returned by 0610. More...
 
struct  UserFrameWriteRequest
 User-frame registration-data write request (1610, subcommand 0000). More...
 

Typedefs

Diagnostic And Transport Helper Types

CPU-model response payload returned by cpu-model.

using CompletionHandler = void(*)(void *user, Status status)
 Completion callback used by the async client.
 

Enumerations

enum class  DecodeStatus : std::uint8_t { Incomplete , Complete , Error }
 High-level result of frame decoding. More...
 
enum class  QualifiedBufferDeviceKind : std::uint8_t { G , HG }
 Qualified buffer-memory family used by helper U... accessors. More...
 
enum class  StatusCode : std::uint8_t {
  Ok = 0 , InvalidArgument , Busy , Timeout ,
  Transport , Framing , SumCheckMismatch , Parse ,
  UnsupportedConfiguration , PlcError , BufferTooSmall , Cancelled
}
 Library-level status code returned by encode, decode, transport, and client operations. More...
 
enum class  FrameKind : std::uint8_t {
  C4 , C3 , C2 , C1 ,
  E1
}
 MC protocol frame family used on the serial link. More...
 
enum class  CodeMode : std::uint8_t { Ascii , Binary }
 Request/response payload encoding. More...
 
enum class  AsciiFormat : std::uint8_t { Format1 , Format2 , Format3 , Format4 }
 ASCII formatting variant for C4 / C3 / C2 serial frames. More...
 
enum class  PlcSeries : std::uint8_t {
  IQ_R , IQ_L , Q_L , QnA ,
  A
}
 PLC family selection used for subcommand and device-layout differences. More...
 
enum class  RouteKind : std::uint8_t { HostStation , MultidropStation }
 Route layout inside the request header. More...
 
enum class  DeviceCode : std::uint8_t {
  X , Y , M , L ,
  SM , F , V , B ,
  D , SD , W , TS ,
  TC , TN , STS , STC ,
  STN , CS , CC , CN ,
  SB , SW , S , DX ,
  DY , LTS , LTC , LTN ,
  LSTS , LSTC , LSTN , LCS ,
  LCC , LCN , LZ , Z ,
  R , RD , ZR , G ,
  HG
}
 Device-family identifier used by the request codecs. More...
 
enum class  BitValue : std::uint8_t { Off = 0 , On = 1 }
 Logical single-bit value used by bit read/write APIs. More...
 
enum class  RemoteOperationMode : std::uint16_t { DoNotExecuteForcibly = 0x0001 , ExecuteForcibly = 0x0003 }
 Conflict-handling mode for remote RUN / PAUSE. More...
 
enum class  RemoteRunClearMode : std::uint8_t { DoNotClear = 0x00 , ClearOutsideLatchRange = 0x01 , AllClear = 0x02 }
 Clear scope applied during remote RUN initialization. More...
 
enum class  GlobalSignalTarget : std::uint8_t { ReceivedSide = 0x00 , X1A = 0x01 , X1B = 0x02 }
 C24 global-signal selector used by command 1618. More...
 
enum class  ResponseType : std::uint8_t { SuccessData , SuccessNoData , PlcError }
 Decoded PLC response class before command-specific parsing. More...
 

Functions

constexpr BitValue sparse_native_requested_bit_value (std::uint32_t raw_value) noexcept
 Returns the requested-point value from a sparse native bit result word.
 
constexpr std::uint16_t sparse_native_mask_word (std::uint32_t raw_value) noexcept
 Returns the raw 16-point mask word from a sparse native bit result.
 
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.
 
constexpr const char * qualified_buffer_kind_name (QualifiedBufferDeviceKind kind) noexcept
 Returns "G" or "HG" for the helper device kind.
 
constexpr std::uint32_t qualified_buffer_word_to_byte_address (std::uint32_t word_address) noexcept
 Converts a qualified word address to the corresponding module-buffer byte address.
 
Status parse_qualified_buffer_word_device (std::string_view text, QualifiedBufferWordDevice &out_device) noexcept
 Parses a helper qualified device string such as U3E0\\G10 or U3E0\\HG20.
 
Status make_qualified_buffer_read_words_request (const QualifiedBufferWordDevice &device, std::uint16_t word_length, ModuleBufferReadRequest &out_request) noexcept
 Builds a module-buffer read request for a helper qualified word range.
 
Status encode_qualified_buffer_word_values (std::span< const std::uint16_t > words, std::span< std::byte > out_bytes, std::size_t &out_size) noexcept
 Encodes helper qualified word values into little-endian module-buffer bytes.
 
Status make_qualified_buffer_write_words_request (const QualifiedBufferWordDevice &device, std::span< const std::uint16_t > words, std::span< std::byte > byte_storage, ModuleBufferWriteRequest &out_request, std::size_t &out_byte_count) noexcept
 Builds a module-buffer write request for helper qualified word access.
 
Status decode_qualified_buffer_word_values (std::span< const std::byte > bytes, std::span< std::uint16_t > out_words) noexcept
 Decodes little-endian module-buffer bytes into helper qualified word values.
 
constexpr Status ok_status () noexcept
 Returns the default success status.
 
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.
 

Variables

constexpr std::size_t kMaxRequestFrameBytes
 
constexpr std::size_t kMaxResponseFrameBytes
 
constexpr std::size_t kMaxRequestDataBytes
 
constexpr std::size_t kMaxBatchWordPoints
 
constexpr std::size_t kMaxBatchBitPointsAscii
 
constexpr std::size_t kMaxBatchBitPointsBinary
 
constexpr std::size_t kMaxRandomAccessItems
 
constexpr std::size_t kMaxMultiBlockCount
 
constexpr std::size_t kMaxMonitorItems
 
constexpr std::size_t kMaxLoopbackBytes
 
constexpr std::size_t kMaxUserFrameRegistrationBytes = 80U
 
constexpr std::size_t kCpuModelNameLength = 16
 

Typedef Documentation

◆ CompletionHandler

using mcprotocol::serial::CompletionHandler = typedef void (*)(void* user, Status status)

Completion callback used by the async client.

The callback receives the original user pointer and the final request status.

Definition at line 651 of file types.hpp.

Enumeration Type Documentation

◆ AsciiFormat

ASCII formatting variant for C4 / C3 / C2 serial frames.

Enumerator
Format1 

ENQ/STX/ETX layout without CR/LF.

Format2 

Format1 plus a 1-byte block number used for request/response pairing on 2C/3C/4C.

Format3 

STX-only layout commonly used on serial MC links.

Format4 

CR/LF terminated layout often used by host-facing bring-up tools.

Definition at line 169 of file types.hpp.

◆ BitValue

Logical single-bit value used by bit read/write APIs.

Enumerator
Off 
On 

Definition at line 243 of file types.hpp.

◆ CodeMode

Request/response payload encoding.

Enumerator
Ascii 

Text-encoded command data and response data.

Binary 

Compact binary command data and response data.

Definition at line 161 of file types.hpp.

◆ DecodeStatus

High-level result of frame decoding.

Enumerator
Incomplete 

More bytes are required before a full frame can be decoded.

Complete 

One full frame was decoded successfully.

Error 

The byte stream is invalid for the selected frame configuration.

Definition at line 26 of file codec.hpp.

◆ DeviceCode

Device-family identifier used by the request codecs.

Enumerator
SM 
SD 
TS 
TC 
TN 
STS 
STC 
STN 
CS 
CC 
CN 
SB 
SW 
DX 
DY 
LTS 
LTC 
LTN 
LSTS 
LSTC 
LSTN 
LCS 
LCC 
LCN 
LZ 
RD 
ZR 
HG 

Definition at line 198 of file types.hpp.

◆ FrameKind

MC protocol frame family used on the serial link.

Enumerator
C4 

Chapter-8/10/11/13 oriented serial frame with the fullest feature coverage in this repository.

C3 

Shorter ASCII serial frame that reuses the C4 payload codec.

C2 

Smallest ASCII serial frame supported by this repository.

C1 

Legacy ASCII serial frame with its own command naming and routing rules.

E1 

Legacy frame family used by chapter-18 style command layouts.

Definition at line 147 of file types.hpp.

◆ GlobalSignalTarget

C24 global-signal selector used by command 1618.

Enumerator
ReceivedSide 
X1A 
X1B 

Definition at line 262 of file types.hpp.

◆ PlcSeries

PLC family selection used for subcommand and device-layout differences.

Enumerator
IQ_R 
IQ_L 
Q_L 
QnA 

Definition at line 181 of file types.hpp.

◆ QualifiedBufferDeviceKind

Qualified buffer-memory family used by helper U... accessors.

Enumerator
HG 

Definition at line 15 of file qualified_buffer.hpp.

◆ RemoteOperationMode

Conflict-handling mode for remote RUN / PAUSE.

Enumerator
DoNotExecuteForcibly 
ExecuteForcibly 

Definition at line 249 of file types.hpp.

◆ RemoteRunClearMode

Clear scope applied during remote RUN initialization.

Enumerator
DoNotClear 
ClearOutsideLatchRange 
AllClear 

Definition at line 255 of file types.hpp.

◆ ResponseType

Decoded PLC response class before command-specific parsing.

Enumerator
SuccessData 

Successful response carrying payload bytes.

SuccessNoData 

Successful response carrying no payload bytes.

PlcError 

PLC-side error response with an end code / error code.

Definition at line 269 of file types.hpp.

◆ RouteKind

Route layout inside the request header.

Enumerator
HostStation 

Host-station route with fixed station=0, network=0, and pc=FF.

MultidropStation 

Multidrop route where the destination station number is encoded in the frame.

Definition at line 190 of file types.hpp.

◆ StatusCode

Library-level status code returned by encode, decode, transport, and client operations.

Enumerator
Ok 
InvalidArgument 
Busy 
Timeout 
Transport 
Framing 
SumCheckMismatch 
Parse 
UnsupportedConfiguration 
PlcError 
BufferTooSmall 
Cancelled 

Definition at line 8 of file status.hpp.

Function Documentation

◆ decode_qualified_buffer_word_values()

Status mcprotocol::serial::decode_qualified_buffer_word_values ( std::span< const std::byte bytes,
std::span< std::uint16_t out_words 
)
inlinenoexcept

Decodes little-endian module-buffer bytes into helper qualified word values.

Definition at line 248 of file qualified_buffer.hpp.

◆ encode_qualified_buffer_word_values()

Status mcprotocol::serial::encode_qualified_buffer_word_values ( std::span< const std::uint16_t words,
std::span< std::byte out_bytes,
std::size_t out_size 
)
inlinenoexcept

Encodes helper qualified word values into little-endian module-buffer bytes.

Definition at line 188 of file qualified_buffer.hpp.

◆ make_qualified_buffer_read_words_request()

Status mcprotocol::serial::make_qualified_buffer_read_words_request ( const QualifiedBufferWordDevice device,
std::uint16_t  word_length,
ModuleBufferReadRequest out_request 
)
inlinenoexcept

Builds a module-buffer read request for a helper qualified word range.

Definition at line 164 of file qualified_buffer.hpp.

◆ make_qualified_buffer_write_words_request()

Status mcprotocol::serial::make_qualified_buffer_write_words_request ( const QualifiedBufferWordDevice device,
std::span< const std::uint16_t words,
std::span< std::byte byte_storage,
ModuleBufferWriteRequest out_request,
std::size_t out_byte_count 
)
inlinenoexcept

Builds a module-buffer write request for helper qualified word access.

Definition at line 215 of file qualified_buffer.hpp.

◆ make_status()

constexpr Status mcprotocol::serial::make_status ( StatusCode  code,
const char *  message,
std::uint16_t  plc_error_code = 0 
)
inlineconstexprnoexcept

Builds a status value with an optional PLC end code.

Definition at line 42 of file status.hpp.

◆ ok_status()

constexpr Status mcprotocol::serial::ok_status ( )
inlineconstexprnoexcept

Returns the default success status.

Definition at line 37 of file status.hpp.

◆ parse_link_direct_device()

Status mcprotocol::serial::parse_link_direct_device ( std::string_view  text,
LinkDirectDevice out_device 
)
inlinenoexcept

Parses a Jn\\... link-direct device string such as J1\\W100 or J1\\X10.

Definition at line 164 of file link_direct.hpp.

◆ parse_qualified_buffer_word_device()

Status mcprotocol::serial::parse_qualified_buffer_word_device ( std::string_view  text,
QualifiedBufferWordDevice out_device 
)
inlinenoexcept

Parses a helper qualified device string such as U3E0\\G10 or U3E0\\HG20.

Definition at line 94 of file qualified_buffer.hpp.

◆ qualified_buffer_kind_name()

constexpr const char * mcprotocol::serial::qualified_buffer_kind_name ( QualifiedBufferDeviceKind  kind)
constexprnoexcept

Returns "G" or "HG" for the helper device kind.

Definition at line 28 of file qualified_buffer.hpp.

◆ qualified_buffer_word_to_byte_address()

constexpr std::uint32_t mcprotocol::serial::qualified_buffer_word_to_byte_address ( std::uint32_t  word_address)
constexprnoexcept

Converts a qualified word address to the corresponding module-buffer byte address.

Definition at line 34 of file qualified_buffer.hpp.

◆ sparse_native_mask_word()

constexpr std::uint16_t mcprotocol::serial::sparse_native_mask_word ( std::uint32_t  raw_value)
constexprnoexcept

Returns the raw 16-point mask word from a sparse native bit result.

Keep this raw word visible for diagnostics when the target-specific offset pattern matters.

Definition at line 71 of file codec.hpp.

◆ sparse_native_requested_bit_value()

constexpr BitValue mcprotocol::serial::sparse_native_requested_bit_value ( std::uint32_t  raw_value)
constexprnoexcept

Returns the requested-point value from a sparse native bit result word.

On 2C/3C/4C, native sparse bit reads (0403) and monitor reads (0802) return the addressed point inside a 16-point mask word. The requested head device is represented by bit 0 of that returned word.

Definition at line 64 of file codec.hpp.

Variable Documentation

◆ kCpuModelNameLength

constexpr std::size_t mcprotocol::serial::kCpuModelNameLength = 16
constexpr

Definition at line 144 of file types.hpp.

◆ kMaxBatchBitPointsAscii

constexpr std::size_t mcprotocol::serial::kMaxBatchBitPointsAscii
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII
Definition types.hpp:43

Definition at line 131 of file types.hpp.

◆ kMaxBatchBitPointsBinary

constexpr std::size_t mcprotocol::serial::kMaxBatchBitPointsBinary
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY
Definition types.hpp:47

Definition at line 133 of file types.hpp.

◆ kMaxBatchWordPoints

constexpr std::size_t mcprotocol::serial::kMaxBatchWordPoints
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS
Definition types.hpp:39

Definition at line 129 of file types.hpp.

◆ kMaxLoopbackBytes

constexpr std::size_t mcprotocol::serial::kMaxLoopbackBytes
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES
Definition types.hpp:63

Definition at line 141 of file types.hpp.

◆ kMaxMonitorItems

constexpr std::size_t mcprotocol::serial::kMaxMonitorItems
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS
Definition types.hpp:59

Definition at line 139 of file types.hpp.

◆ kMaxMultiBlockCount

constexpr std::size_t mcprotocol::serial::kMaxMultiBlockCount
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT
Definition types.hpp:55

Definition at line 137 of file types.hpp.

◆ kMaxRandomAccessItems

constexpr std::size_t mcprotocol::serial::kMaxRandomAccessItems
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS
Definition types.hpp:51

Definition at line 135 of file types.hpp.

◆ kMaxRequestDataBytes

constexpr std::size_t mcprotocol::serial::kMaxRequestDataBytes
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES
Definition types.hpp:35

Definition at line 127 of file types.hpp.

◆ kMaxRequestFrameBytes

constexpr std::size_t mcprotocol::serial::kMaxRequestFrameBytes
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES
Definition types.hpp:27

Definition at line 123 of file types.hpp.

◆ kMaxResponseFrameBytes

constexpr std::size_t mcprotocol::serial::kMaxResponseFrameBytes
constexpr
Initial value:
=
#define MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES
Definition types.hpp:31

Definition at line 125 of file types.hpp.

◆ kMaxUserFrameRegistrationBytes

constexpr std::size_t mcprotocol::serial::kMaxUserFrameRegistrationBytes = 80U
constexpr

Definition at line 143 of file types.hpp.