Commit 7259914
authored
fix(transport): multiple devices on same bus use correct slave ID (#235)
Multiple devices sharing the same serial port were using the wrong slave ID
because TransportManager pooled transports by connection key (excluding slave ID)
and modbus-serial client had a static slave ID set once at creation time.
Solution: SlaveTransport wrapper
- Created SlaveTransport class that binds a slave ID to a shared client
- TransportManager now pools modbus-serial clients (not Transport instances)
- Each device gets its own SlaveTransport with its own slave ID
- Slave ID is set before each operation within a mutex-protected context
- Multiple devices on same bus share the same client and mutex
Changes:
- Add SlaveTransport class implementing Transport interface
- Modify TransportManager to pool clients by physical connection
- SlaveTransport sets slave ID before each operation
- Shared mutex ensures serialized access across all slaves
- Absorb retry logic into SlaveTransport
- Add comprehensive documentation for shared resource ownership
- Enable e2e test for multiple devices on same bus
Tests:
- Add comprehensive SlaveTransport tests (21 tests)
- Update TransportManager tests for new architecture (17 tests)
- All 1534 tests pass
- E2E test validates multiple devices work correctly
Closes #1711 parent bc341ec commit 7259914
6 files changed
Lines changed: 970 additions & 194 deletions
File tree
- packages/transport/src
- tests/e2e/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
0 commit comments