HardFOC Core
API reference
Loading...
Searching...
No Matches
Classes | Namespaces
PipePort.h File Reference

Host pipe bus: a UNIX-socket hub that behaves like a CAN bus, and the ICanPort that joins it (POSIX hosts only). More...

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
#include "HfCanPort.h"

Go to the source code of this file.

Classes

class  hf::can::PipeHub
 The bus: forwards datagrams between participants. More...
 
class  hf::can::PipePort
 ICanPort over a PipeHub. More...
 
struct  hf::can::PipePort::Options
 

Namespaces

namespace  hf
 
namespace  hf::can
 

Detailed Description

Host pipe bus: a UNIX-socket hub that behaves like a CAN bus, and the ICanPort that joins it (POSIX hosts only).

CI runners cannot always load vcan, so host tests can run the node over this bus instead (Vortex CANopen design §9.4). Every participant connects to the hub's UNIX stream socket; the hub forwards each datagram to every other participant, never back to the sender (like a CAN controller without self-reception). Frames travel as §7.2 frame records (HfCanFrameRecord.h), each datagram behind a u16 length, so the python-can plugin and the Wi-Fi tunnel share the codec.

The hub never drops: it buffers per participant and stops reading a sender while a receiver is behind (bounded by PipeHub::kMaxBacklog), so a full bus applies back-pressure instead of losing frames.

PipePort::Send queues the frame (bounded queue, QueueFull when full) and returns; an I/O thread batches queued frames into datagrams, writes them, reads incoming datagrams and calls the RX sink. After freeing queue space it calls the TX-done sink. When the RX sink refuses a frame (the CO driver's ring is full) the port holds it, stops reading the socket and offers it again a millisecond later, so back-pressure reaches the sender.

SPDX-License-Identifier: GPL-3.0-or-later