Skip to content

Feat/rpi robus - #502

Merged
nicolas-rabault merged 11 commits into
rc_3.2.0from
feat/RPI_robus
Apr 27, 2026
Merged

Feat/rpi robus#502
nicolas-rabault merged 11 commits into
rc_3.2.0from
feat/RPI_robus

Conversation

@nicolas-rabault

Copy link
Copy Markdown
Member

By submiting this PR, you agree with the associated license MIT) and with our Contributor License Agreement (CLA).

Before to begin

Thank you for contributing to the Luos project!

Before to begin, please follow these steps:

  • Ensure that this PR is not a duplicate.

Feel free to read the Luos contribution's guidelines and the documentation page to have more insight about how to contribute to Luos.

PR Description section

Description and dependencies

Please include here a summary of the changes and the related issue. List any dependencies that are required for this change.

Changes

Please choose the relevant options:

  • New feature (non-breaking change which adds functionality)

Related issue(s)

Provide a list of the related issues that will be fixed by this PR.


WARNING: Do not edit the checklist below.


Developer section

  • [Documentation] is up to date with new feature
  • [Tests] are passed OK (non regression, new features & bug fixes)
  • [Code Quality] please check if:
    • Each function has a header (description, inputs, outputs)
    • Code is commented (particularly in hard to understand areas)
    • There are no new warnings that can be corrected
    • Commits policy is respected (constitancy commits, clear commits comments)

QA section

  • [Review] tests for new features have been reviewed
  • [Changelog] is up-to-date with expected tags
    🆕 Feature: [Feature] Description...
    🆕 Added: [Feature] Description...
    🆕 Changed: [Feature] Description...
    🛠️ Fix: [Feature] Description...

nicolas-rabault and others added 10 commits April 10, 2026 18:57
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On BCM-family PL011 (RPi), tcdrain() blocks ~7.9 ms per call regardless
of frame size. The driver polls FR.BUSY which is sticky on this hardware;
TIOCOUTQ returns 0 immediately after write(), confirming the kernel TX
buffer is drained well before tcdrain returns. Measured on a 10-byte
frame at 1 Mbps (100 µs wire time): tcdrain=7578 µs p50, write=20 µs
p50 — tcdrain accounted for 96% of the P1 RTT floor.

Replace tcdrain() with clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME)
for (size * 10 bits * ns_per_bit) + 50 µs margin. The per-bit timing
uses the existing timeout_ns_per_bit, so higher baudrates work without
further changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After a valid frame's CRC, the Robus state machine sets
ctx.rx.callback = Recep_Drop to ignore trailing garbage until
Recep_Timeout fires DEFAULT_TIMEOUT bit-times later. This assumes
an inter-frame silence at least as long as the timeout.

On RS485 half-duplex without bus arbitration (the Linux HAL has
GetTxLockState stubbed to false), two uncoordinated nodes can TX
back-to-back with a gap far shorter than that. Observed in S1:
Tartine's bg_pub and its CMD_ECHO_REPLY arrived 14 µs apart — all
ten reply bytes were dropped by Recep_Drop, producing a 300 ms
timeout on iter 528.

When the RX thread reads a byte while the callback is Recep_Drop,
immediately call Recep_Reset so the byte is treated as the start
of a new frame. Fix is Linux-HAL-local; MCU behavior is untouched.

Verified via event trace: echo bytes matched cleanly during the
timeout (no TX collision), and reply bytes were fully received
within 700 µs but not dispatched until the next iter's TX kicked
the state machine.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mirrors the native gate_wscom project structure but runs the Luos
network over Robus (RS485 on RPI GPIO via the LINUX Robus HAL). The
Gate exposes itself to external clients over a WebSocket pipe bound
on all interfaces, so pyluos can connect from anywhere on the LAN.

Two build envs: rpi_robus (default, real RS485 hardware) and rpi_ws
(WebSocket broker for dev without hardware).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
port_manager.h conditionally declares PortMng_WatchdogCheck() when
NORT is defined, but on the LINUX HAL NORT is defined inside
robus_hal_config.h (pulled in via robus_hal.h). The previous include
order parsed port_manager.h first, so the prototype was skipped and
robus.c/port_manager.c fell back to an implicit declaration once
NORT got defined later by robus_hal.h. Reorder the includes so the
HAL header is parsed first and NORT is visible to port_manager.h.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
char path_copy[256];
strncpy(path_copy, LUOS_PERSIST_PATH, sizeof(path_copy) - 1);
path_copy[sizeof(path_copy) - 1] = '\0';
mkdir(dirname(path_copy), 0755);
Align assignments, wrap multi-line macro, and fix whitespace to match
the CI clang-format 1.5.0 expectations on files touched by this branch
(engine/IO, robus_network/HAL/LINUX, robus_network/src).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Luos-io Luos-io deleted a comment from sonarqubecloud Bot Apr 23, 2026
@nicolas-rabault
nicolas-rabault merged commit d72265a into rc_3.2.0 Apr 27, 2026
48 of 49 checks passed
@nicolas-rabault
nicolas-rabault deleted the feat/RPI_robus branch April 27, 2026 14:29
@nicolas-rabault nicolas-rabault mentioned this pull request Apr 27, 2026
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