Skip to content

Fix routing of unsupported MEI types - #2975

Merged
janiversen merged 2 commits into
pymodbus-dev:devfrom
MrAlaskan:fix/mei-2b-non-0e-routing
Jul 23, 2026
Merged

Fix routing of unsupported MEI types#2975
janiversen merged 2 commits into
pymodbus-dev:devfrom
MrAlaskan:fix/mei-2b-non-0e-routing

Conversation

@MrAlaskan

Copy link
Copy Markdown
Contributor

Summary

Prevent unsupported Encapsulated Interface Transport (FC 0x2B) MEI types from being routed to the Read Device Identification implementation.

Problem

Function code 0x2B uses the MEI Type field to dispatch requests to different encapsulated interfaces. Read Device Identification is specifically assigned MEI type 0x0E, while 0x0D represents the separately defined CANopen General Reference interface and other ranges are reserved.

Previously, ReadDeviceInformationRequest was registered as both the base handler for function 0x2B and the handler for MEI type 0x0E. When the decoder received another MEI type and could not find a matching subtype, it retained the base ReadDeviceInformationRequest object. The server could consequently process an unsupported or reserved MEI request as Read Device Identification and return a normal 0x0E response with semantics unrelated to the original request.

Changes

This change introduces a generic Encapsulated Interface Transport dispatch PDU as the base handler for function 0x2B. MEI type 0x0E continues to route to ReadDeviceInformationRequest, while unsupported and reserved MEI types remain on the generic handler and return ILLEGAL_FUNCTION (0x01) instead of entering the device-identification logic.

Tests verify that 0x0E still routes correctly and that MEI types 0x00, 0x0D, 0x0F, and 0xFF are not interpreted as Read Device Identification requests and return the expected exception.

@janiversen janiversen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@janiversen
janiversen merged commit 5f9e36b into pymodbus-dev:dev Jul 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants