IoT::CANopen

class PDO

File Information

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

Description

This class implements the CANopen PDO (Process Data Object) protocol.

Member Summary

Member Functions: addCOBIDs, onFrameReceived, removeCOBIDs, requestPDO, transmitPDO

Nested Classes

struct PDOTransfer

 

Constructors

PDO

PDO(
    CANBus & canBus
);

Creates the PDO object using the given CANBus object.

Destructor

~PDO

~PDO();

Destroys the Time object.

Member Functions

addCOBIDs

void addCOBIDs(
    Poco::UInt32 firstCOBID,
    Poco::UInt32 count = 1
);

Adds a range of COB-IDs to the internal set of COB-IDs for receiving PDOs or PDO transmission requests.

removeCOBIDs

void removeCOBIDs(
    Poco::UInt32 firstCOBID,
    Poco::UInt32 count = 1
);

Removes a range of COB-IDs from the internal set of COB-IDs for receiving PDOs or PDO transmission requests.

requestPDO

void requestPDO(
    Poco::UInt32 cobID
);

Requests transmission of the PDO identified by the given COB-ID by sending a retransmission request (RTR) for the given COB-ID.

The PDO transmitted by the peer device in response will be reported by firing the pdoReceived event. In order to receive the event, the respective COB-ID must have been enabled with a call to addCOBIDs().

requestPDO

int requestPDO(
    Poco::UInt32 cobID,
    Poco::UInt8 size,
    char * data,
    Poco::Timespan timeout
);

Requests transmission of the PDO identified by the given COB-ID by sending a retransmission request (RTR) for the given COB-ID.

This method is synchronous and waits for reception of a PDO until the given timeout expires. If a PDO is received, the PDO's raw data (up to 8 bytes) is copied to the given buffer, which must have sufficient size, and the number of bytes received (1 .. 8) is returned. If the buffer is smaller than required, only the number of bytes that fit into the buffer are copied. If no PDO is received within the given timeout, -1 is returned.

Please note that it is not safe to call this method simultaneously from multiple threads for the same COB-ID. Also, it is not recommended to mix synchronous and asynchronous PDO requests for the same COB-ID.

transmitPDO

void transmitPDO(
    Poco::UInt32 cobID,
    Poco::UInt8 size,
    const char * data
);

Transmits a PDO.

onFrameReceived protected

void onFrameReceived(
    const CANFrame & frame
);

Handles PDO frames.

Variables

pdoReceived

Poco::BasicEvent < const PDOTransfer > pdoReceived;

Fired when a PDO has been received.

pdoRequested

Poco::BasicEvent < const Poco::UInt32 > pdoRequested;

Fired when a retransmission request (RTR) for a PDO has been received. The COB-ID of the PDO is given as argument.

Securely control IoT edge devices from anywhere   Connect a Device