PlatformIO
Version 0.2.3 trims the registry tarball to the library-facing files while keeping the PlatformIO packaging metadata and simpler host-side entrypoints.
Main Files
platformio.inilibrary.jsonlibrary.propertiesinclude/mcprotocol_serial.hpp
Available Environments
native-examplerpipico-arduino-exampleesp32-c3-devkitm-1-examplerpipico-arduino-uart-exampleesp32-c3-devkitm-1-uart-examplemega2560-arduino-uart-examplemega2560-arduino-uart-example-ultra-minimalnative-example-ultra-minimalrpipico-arduino-example-ultra-minimalesp32-c3-devkitm-1-example-ultra-minimal
Run them with:
pio run -e native-example
pio run -e rpipico-arduino-example
pio run -e esp32-c3-devkitm-1-example
pio run -e rpipico-arduino-uart-example
pio run -e esp32-c3-devkitm-1-uart-example
pio run -e mega2560-arduino-uart-example
pio run -e mega2560-arduino-uart-example-ultra-minimal
pio run -e native-example-ultra-minimal
pio run -e rpipico-arduino-example-ultra-minimal
pio run -e esp32-c3-devkitm-1-example-ultra-minimal
Reduced Profile
The normal PlatformIO examples already use a reduced-footprint profile.
That profile keeps batch read/write, cpu-model, and loopback, compiles out the other command
families, and also compiles the codec down to 4C + ASCII only.
MelsecSerialClient: about18,984 bytes -> 2,168 bytesESP32-C3 RAM:36,740 bytes -> 15,868 bytesESP32-C3 Flash:289,914 bytes -> 264,024 bytesMega 2560 RAM:7,717 bytes -> 6,695 bytesMega 2560 Flash:25,420 bytes -> 20,806 bytes
Ultra-minimal Profile
The ultra-minimal environments are for cases where you only want small batch read/write.
They also compile out cpu-model and loopback, and shrink the fixed frame/data buffers to
256 / 256 / 128 bytes. Like the reduced profile, they keep only 4C + ASCII in the codec.
MelsecSerialClient: about18,984 bytes -> 792 bytesESP32-C3 RAM:36,740 bytes -> 14,508 bytesESP32-C3 Flash:289,914 bytes -> 261,046 bytesMega 2560 RAM:5,961 bytes -> 4,983 bytesMega 2560 Flash:23,632 bytes -> 18,716 bytesRP2040 RAM:41,512 bytesRP2040 Flash:4,850 bytes
Build-time Tuning Macros
What can be compiled out:
- build-target unit
CMake can drop host-side pieces as separate targets:
MCPROTOCOL_BUILD_HOST_SUPPORT=OFFremoveshost_syncplus the host serial backend, andMCPROTOCOL_BUILD_CLI=OFFremovesmcprotocol_cli - buffer-capacity unit The fixed request / response / payload capacities are independent macros
- command-family unit Each feature switch below removes one whole command family from the codec and client surface
- codec-family unit You can remove whole code modes and whole frame families from the codec dispatch
- not yet a trim unit This repository does not yet cut individual commands inside one family, per-device paths, or per-PLC-profile support as separate compile-time switches
Capacity tuning:
MCPROTOCOL_SERIAL_MAX_REQUEST_FRAME_BYTESMCPROTOCOL_SERIAL_MAX_RESPONSE_FRAME_BYTESMCPROTOCOL_SERIAL_MAX_REQUEST_DATA_BYTESMCPROTOCOL_SERIAL_MAX_RANDOM_ACCESS_ITEMSMCPROTOCOL_SERIAL_MAX_MULTI_BLOCK_COUNTMCPROTOCOL_SERIAL_MAX_MONITOR_ITEMSMCPROTOCOL_SERIAL_MAX_LOOPBACK_BYTES
Feature switches:
MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDSMCPROTOCOL_SERIAL_ENABLE_MULTI_BLOCK_COMMANDSMCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDSMCPROTOCOL_SERIAL_ENABLE_HOST_BUFFER_COMMANDSMCPROTOCOL_SERIAL_ENABLE_MODULE_BUFFER_COMMANDSMCPROTOCOL_SERIAL_ENABLE_CPU_MODEL_COMMANDSMCPROTOCOL_SERIAL_ENABLE_LOOPBACK_COMMANDS
Codec switches:
MCPROTOCOL_SERIAL_ENABLE_ASCII_MODEMCPROTOCOL_SERIAL_ENABLE_BINARY_MODEMCPROTOCOL_SERIAL_ENABLE_FRAME_C4MCPROTOCOL_SERIAL_ENABLE_FRAME_C3MCPROTOCOL_SERIAL_ENABLE_FRAME_C2MCPROTOCOL_SERIAL_ENABLE_FRAME_C1MCPROTOCOL_SERIAL_ENABLE_FRAME_E1
Practical examples:
MCPROTOCOL_SERIAL_ENABLE_RANDOM_COMMANDS=0removes the whole random-read / random-write familyMCPROTOCOL_SERIAL_ENABLE_MONITOR_COMMANDS=0removes0801/0802monitor as one familyMCPROTOCOL_SERIAL_ENABLE_BINARY_MODE=0removes all binary codec branches at onceMCPROTOCOL_SERIAL_ENABLE_FRAME_C1=0removes the whole1Cframe family at onceMCPROTOCOL_SERIAL_ENABLE_FRAME_C4=1with the other frame macros=0keeps only4C
CMake Feature Profiles
The CMake build exposes the same footprint presets:
cmake -S . -B build-reduced -DMCPROTOCOL_FEATURE_PROFILE=reduced -DMCPROTOCOL_BUILD_HOST_SUPPORT=OFF -DMCPROTOCOL_BUILD_CLI=OFF -DMCPROTOCOL_BUILD_EXAMPLES=ON -DBUILD_TESTING=OFF
cmake -S . -B build-ultra -DMCPROTOCOL_FEATURE_PROFILE=ultra -DMCPROTOCOL_BUILD_HOST_SUPPORT=OFF -DMCPROTOCOL_BUILD_CLI=OFF -DMCPROTOCOL_BUILD_EXAMPLES=ON -DBUILD_TESTING=OFF
Profile behavior:
full: complete host-oriented build, including host sync and CLIreduced: core-only build, smaller buffers, no random/multi-block/monitor/host-buffer/module-buffer, and codec limited to4C + ASCIIultra: reduced profile plus nocpu-model, noloopback, and the same4C + ASCIIcodec limit
Non-full profiles are treated as core-only by CMake, so host sync and CLI are turned off
automatically. If BUILD_TESTING is left ON, CMake also disables it automatically for these
profiles.