IoT::CANopen

class CANBus

File Information

Library: IoT/CANopen
Package: CANopen
Header: IoT/CANopen/CANBus.h

Description

A CANBus object sends and receives CAN frames over a physical CAN bus. Actual sending and receiving is done via a CANInterface. Scheduling of sent frames is done using a FrameScheduler. Received frames are reported via an event.

Inheritance

Direct Base Classes: Poco::Runnable

All Base Classes: Poco::Runnable

Member Summary

Member Functions: onInterfaceError, run, sendFrame, start, stop

Inherited Functions: run

Enumerations

CANBitrates

Supported CANopen bus bit rates.

CAN_BITRATE_10_KBPS = 10000

10 KBit/s

CAN_BITRATE_20_KBPS = 20000

20 KBit/s

CAN_BITRATE_50_KBPS = 50000

50 KBit/s

CAN_BITRATE_125_KBPS = 125000

125 KBit/s

CAN_BITRATE_250_KBPS = 250000

250 KBit/s

CAN_BITRATE_500_KBPS = 500000

500 KBit/s

CAN_BITRATE_800_KBPS = 800000

800 KBit/s

CAN_BITRATE_1000_KBPS = 1000000

1 MBit/s

Constructors

CANBus

CANBus(
    CANInterface & canInterface,
    long interFrameDelay
);

Creates the FrameScheduler with the given CANInterface and inter-frame delay in milliseconds.

CANBus

CANBus(
    CANInterface & canInterface,
    int bitrate,
    int busUtilization
);

Creates the FrameScheduler with the given CANInterface, bitrate (bits per second) and bus utilization in percent (1 - 100).

Destructor

~CANBus virtual

~CANBus();

Destroys the CANBus.

Member Functions

sendFrame inline

void sendFrame(
    const CANFrame & frame
);

Enqueues the given CANFrame on the send queue.

start

void start();

Starts sending and receiving frames.

stop

void stop();

Stops sending and receiving frames.

onInterfaceError protected

void onInterfaceError(
    const Poco::Exception & exc
);

run protected virtual

void run();

Variables

frameReceived

Poco::BasicEvent < const CANFrame > frameReceived;

Fired when a valid CAN frame has been received.

The delegate should process the frame as fast as possible, as reception of further frames will be blocked until all delegates complete.

interfaceError

Poco::BasicEvent < const Poco::Exception > interfaceError;

Fired when a send or receive operation on the CAN interface fails with an exception.

Securely control IoT edge devices from anywhere   Connect a Device