Skip to content

Conversation

@logicallysynced
Copy link

@logicallysynced logicallysynced commented Jan 10, 2026

Adds a TCP client transport for EX-IOExpander's, so CommandStation can talk to one or more IOExpander's over a network stack (WiFi/Ethernet) instead of I2C.

This implementation is very preliminary and not well tested. I'm sharing as a proof of concept rather than a complete implementation.

This is the CommandStation side of the codebase, for the IOExpander, please see:
DCC-EX/EX-IOExpander#65

This code builds off another PR which introduced shift register support for IOExpander:
#501

  • Introduces a TCP-based EX-IOExpander HAL implementation that mirrors the current request/response behavior used over I2C.
  • Supports multiple IOExpanders concurrently by instantiating one TCP connection per configured expander (unique IP per device, shared port supported).
  • Keeps the existing EX-IOExpander command set intact (INIT / pin map / read digital+analog / write digital+analog / shift-in/out / version), but frames messages for TCP.
  • Each "EXIOExpander_TCP" entry connects to <expander_ip>:<port> and performs EXIOINIT to validate pin-count and set first vPIN and subsequent poll cycles for EXIORDD / EXIORDAN and on-demand writes (EXIOWRD, EXIOWRAN, etc.)
  • Uses a simple frame format: [CMD][LEN][PAYLOAD...] with corresponding responses.
  • Error handling includes timeouts and reconnect on disconnect.

The HAL driver can be called using the following:

HAL(EXIOExpander_TCP, VPIN, NUM_PINS, IP ADDRESS, OPTIONAL_PORT )

Examples:
HAL(EXIOExpander_TCP, 800, 16, 192, 168, 1, 200) // default port 2560
HAL(EXIOExpander_TCP, 800, 16, 192, 168, 1, 200, 2560) // explicit port

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.

1 participant