RTOS & Firmware Stacks
Modbus RTU and RS-485 DE-turnaround testing in CI
Catch truncated last bytes from dropping RS-485 DE on TXE instead of TC before shipping industrial fieldbus firmware.
The most common RS-485 firmware bug clears the MAX3485 DE pin when the UART TXE (transmit buffer empty) flag fires instead of waiting for TC (transmission complete). The stop bit and final CRC byte get clipped off the wire.
CircuitTwin wires your MCU UART and DE GPIO through a half-duplex RS-485 transceiver twin (MAX3485), checking exact frame integrity, reflected CRC-16 and silent-interval framing in CI.
Modbus RTU faults verified in CI
| Bug class | Root cause | Twin check |
|---|---|---|
Truncated CRC byte | DE cleared on TXE instead of TC | Virtual RS-485 peer logs CRC-16 failure |
Wrong CRC byte order | Transmitting MSB first instead of LSB first | Peer rejects request with silent drop |
Bus collision | Master polls while slave still drives bus | RS-485 transceiver flags contention event |
Local CLI workflow
Shell - run Modbus RTU RS-485 test suite
ct test run --json --junit results/modbus.xml tests/modbus-rtu.suite.yamlSuite & fault configuration
tests/modbus-rtu.suite.yaml
version: 1
board: nucleo-f446re
firmware: build/modbus_slave.elf
tests:
- name: read-holding-registers-and-bad-crc
timeout_ms: 2000
expect:
console_contains: "MODBUS_FC03_OK"
exit_code: 0CI pipeline integration
.github/workflows/modbus-ci.yml
name: Modbus RTU Twin CI
on: [push, pull_request]
jobs:
modbus:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cmake --build build
- uses: circuittwin/action@v1
with:
suite: tests/modbus-rtu.suite.yamlTroubleshooting checklist
| Symptom | Fix |
|---|---|
| Last byte of response missing on RS-485 bus | Wait for USART_SR_TC (transmission complete) before pulling the MAX3485 DE pin low. |
| Slave ignores valid FC03 request | Verify CRC-16/Modbus low-byte-first wire order using the Embedded CRC Calculator. |
Frequently asked questions
| Question | Answer |
|---|---|
| Can CircuitTwin verify half-duplex RS-485 DE timing automatically? | Yes. Board definitions support rs485_buses bound to transceiver twins like MAX3485 so premature DE de-assertion corrupts the wire frame just like real silicon. |