MC Protocol Serial C++ 0.2.3
MC protocol serial library for MCU-oriented environments
Loading...
Searching...
No Matches
types.hpp File Reference

Public request, response, configuration, and callback types for the serial MC protocol library. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include "mcprotocol/serial/span_compat.hpp"
#include "mcprotocol/serial/status.hpp"

Go to the source code of this file.

Classes

struct  mcprotocol::serial::TimeoutConfig
 Timeout settings used by the frame decoder and async client. More...
 
struct  mcprotocol::serial::RouteConfig
 Route header fields for serial MC requests. More...
 
struct  mcprotocol::serial::ProtocolConfig
 Top-level protocol configuration shared by codecs and client requests. More...
 
struct  mcprotocol::serial::DeviceAddress
 Device code plus numeric address. More...
 
struct  mcprotocol::serial::ExtendedFileRegisterAddress
 Extended file-register address using block number plus R word number. More...
 
struct  mcprotocol::serial::BatchReadWordsRequest
 
struct  mcprotocol::serial::BatchReadBitsRequest
 Contiguous bit-read request (0401 bit path). More...
 
struct  mcprotocol::serial::BatchWriteWordsRequest
 Contiguous word-write request (1401). More...
 
struct  mcprotocol::serial::BatchWriteBitsRequest
 Contiguous bit-write request (1401 bit path). More...
 
struct  mcprotocol::serial::ExtendedFileRegisterBatchReadWordsRequest
 
struct  mcprotocol::serial::ExtendedFileRegisterDirectBatchReadWordsRequest
 Direct extended file-register batch read (NR on 1C QnA-common, chapter-18 direct path on 1E). More...
 
struct  mcprotocol::serial::ExtendedFileRegisterBatchWriteWordsRequest
 Extended file-register batch write (EW on 1C ACPU-common, chapter-18 block path on 1E). More...
 
struct  mcprotocol::serial::ExtendedFileRegisterDirectBatchWriteWordsRequest
 Direct extended file-register batch write (NW on 1C QnA-common, chapter-18 direct path on 1E). More...
 
struct  mcprotocol::serial::ExtendedFileRegisterRandomWriteWordItem
 One item inside extended file-register random write (ET on 1C, chapter-18 on 1E). More...
 
struct  mcprotocol::serial::ExtendedFileRegisterMonitorRegistration
 Extended file-register monitor registration (EM on 1C, chapter-18 on 1E). More...
 
struct  mcprotocol::serial::RandomReadItem
 
struct  mcprotocol::serial::RandomReadRequest
 Native random-read request made of sparse word/dword items. More...
 
struct  mcprotocol::serial::RandomWriteWordItem
 One word or double-word item inside native random write (1402 word path). More...
 
struct  mcprotocol::serial::RandomWriteBitItem
 One bit item inside native random write (1402 bit path). More...
 
struct  mcprotocol::serial::MultiBlockReadBlock
 One block inside native multi-block read (0406). More...
 
struct  mcprotocol::serial::MultiBlockReadRequest
 Native multi-block read request composed of multiple contiguous blocks. More...
 
struct  mcprotocol::serial::MultiBlockWriteBlock
 One block inside native multi-block write (1406). More...
 
struct  mcprotocol::serial::MultiBlockWriteRequest
 Native multi-block write request composed of multiple contiguous blocks. More...
 
struct  mcprotocol::serial::MultiBlockReadBlockResult
 Parsed layout description for one block returned by parse_multi_block_read_response(). More...
 
struct  mcprotocol::serial::MonitorRegistration
 
struct  mcprotocol::serial::UserFrameReadRequest
 
struct  mcprotocol::serial::UserFrameRegistrationData
 User-frame registration-data payload returned by 0610. More...
 
struct  mcprotocol::serial::UserFrameWriteRequest
 User-frame registration-data write request (1610, subcommand 0000). More...
 
struct  mcprotocol::serial::UserFrameDeleteRequest
 User-frame registration-data delete request (1610, subcommand 0001). More...
 
struct  mcprotocol::serial::GlobalSignalControlRequest
 C24 global-signal ON/OFF request (1618). More...
 
struct  mcprotocol::serial::HostBufferReadRequest
 
struct  mcprotocol::serial::HostBufferWriteRequest
 Host-buffer write request (1613). More...
 
struct  mcprotocol::serial::ModuleBufferReadRequest
 Module-buffer byte read request (0601 helper path). More...
 
struct  mcprotocol::serial::ModuleBufferWriteRequest
 Module-buffer byte write request (1601 helper path). More...
 
struct  mcprotocol::serial::CpuModelInfo
 
struct  mcprotocol::serial::Rs485Hooks
 Optional RS-485 callbacks used by the async client around TX start/end. More...
 

Namespaces

namespace  mcprotocol
 
namespace  mcprotocol::serial
 

Macros

Compile-time Capacity And Feature Knobs

These macros are intended for footprint tuning on MCU builds.

#define MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES   4096U
 
#define MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES   4096U
 
#define MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES   3500U
 
#define MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS   960U
 
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII   7904U
 
#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY   3584U
 
#define MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS   192U
 
#define MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT   120U
 
#define MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS   192U
 
#define MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES   960U
 
#define MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS   1
 
#define MCPROTOCOL_SERIAL_ENABLE_ASCII_MODE   1
 
#define MCPROTOCOL_SERIAL_ENABLE_BINARY_MODE   1
 
#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C4   1
 
#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C3   1
 
#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C2   1
 
#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C1   1
 
#define MCPROTOCOL_SERIAL_ENABLE_FRAME_E1   1
 

Typedefs

Diagnostic And Transport Helper Types

CPU-model response payload returned by cpu-model.

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

Enumerations

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

Variables

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

Detailed Description

Public request, response, configuration, and callback types for the serial MC protocol library.

This header is the main data-model reference for the public API. It defines:

  • protocol-selection and routing enums
  • static buffer and feature-limit constants
  • request/response payload structs used by MelsecSerialClient, PosixSyncClient, and CommandCodec
  • callback and transport hook types used by host and MCU integrations

Definition in file types.hpp.

Macro Definition Documentation

◆ MCPROTOCOL_SERIAL_ENABLE_ASCII_MODE

#define MCPROTOCOL_SERIAL_ENABLE_ASCII_MODE   1

Definition at line 95 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_BINARY_MODE

#define MCPROTOCOL_SERIAL_ENABLE_BINARY_MODE   1

Definition at line 99 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDS   1

Definition at line 87 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_FRAME_C1

#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C1   1

Definition at line 115 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_FRAME_C2

#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C2   1

Definition at line 111 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_FRAME_C3

#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C3   1

Definition at line 107 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_FRAME_C4

#define MCPROTOCOL_SERIAL_ENABLE_FRAME_C4   1

Definition at line 103 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_FRAME_E1

#define MCPROTOCOL_SERIAL_ENABLE_FRAME_E1   1

Definition at line 119 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDS   1

Definition at line 79 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS   1

Definition at line 91 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDS   1

Definition at line 83 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS   1

Definition at line 75 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDS   1

Definition at line 71 of file types.hpp.

◆ MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS

#define MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS   1

Definition at line 67 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII

#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_ASCII   7904U

Definition at line 43 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY

#define MCPROTOCOL_SERIAL_MAX_BATCH_BIT_POINTS_BINARY   3584U

Definition at line 47 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS

#define MCPROTOCOL_SERIAL_MAX_BATCH_WORD_POINTS   960U

Definition at line 39 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES

#define MCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES   960U

Definition at line 63 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS

#define MCPROTOCOL_SERIAL_MAX_MONITOR_ITEMS   192U

Definition at line 59 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT

#define MCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNT   120U

Definition at line 55 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS

#define MCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMS   192U

Definition at line 51 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES

#define MCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTES   3500U

Definition at line 35 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES

#define MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTES   4096U

Definition at line 27 of file types.hpp.

◆ MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES

#define MCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTES   4096U

Definition at line 31 of file types.hpp.