CANopen FD Master Library
Making your systems precise, reliable and high-quality - 5.10.01
Functions
PDO service

Functions

ComStatus_tv ComPdoConfig (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint32_t ulIdV, uint8_t ubDlcV, uint8_t ubTypeV, uint16_t uwTimeV)
 
ComStatus_tv ComPdoEnable (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t ubEnableV)
 
void ComPdoEventReceive (uint8_t ubNetV, uint16_t uwPdoNumV)
 
void ComPdoEventTimeout (uint8_t ubNetV, uint16_t uwPdoNumV)
 
ComStatus_tv ComPdoGetCounter (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint32_t *pulCounterV)
 
ComStatus_tv ComPdoGetData (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t *pubDataV)
 
ComStatus_tv ComPdoGetDlc (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t *pubDlcV)
 
ComStatus_tv ComPdoQueueClear (uint8_t ubNetV)
 
ComStatus_tv ComPdoQueueCount (uint8_t ubNetV, uint16_t *puwCountV)
 
ComStatus_tv ComPdoQueueDisable (uint8_t ubNetV)
 
ComStatus_tv ComPdoQueueEnable (uint8_t ubNetV)
 
ComStatus_tv ComPdoQueueFetch (uint8_t ubNetV, CpCanMsg_ts *ptsCanMsgV)
 
ComStatus_tv ComPdoSetData (uint8_t ubNetV, uint16_t uwPdoNumV, uint8_t ubPdoDirV, uint8_t *pubDataV)
 

Detailed Description

The real-time data transfer is performed by means of "Process Data Objects (PDO)". The transfer of PDOs is performed with no protocol overhead. The PDOs correspond to entries in the device Object Dictionary and provide the interface to the application objects. Data type and mapping of application objects into a PDO is determined by a corresponding default PDO mapping structure within the Device Object Dictionary. If variable PDO-mapping is supported the number of PDOs and the mapping of application objects into a PDO may be transmitted to a device during the device configuration process by applying the SDO services (see com_sdo_cln.h) to the corresponding entries of the Object Dictionary. Number and length of PDOs of a device is application specific and are specified within the device profile.

There are two kinds of use for PDOs. The first is data transmission and the second data reception. It is distinguished in Transmit-PDOs (TPDOs) and Receive-PDOs (RPDOs). Devices supporting TPDOs are PDO producer and devices which are able to receive PDOs are called PDO consumer.

In order to access the maximum number of PDOs, the API uses the parameter uwPdoNumV, which is called PDO number. The value for PDO number is 0 to #COM_PDO_RCV_MAX - 1 for Receive PDOs and 0 to #COM_PDO_TRM_MAX - 1 for Transmit PDOs.

Function Documentation

◆ ComPdoConfig()

ComStatus_tv ComPdoConfig ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint32_t  ulIdV,
uint8_t  ubDlcV,
uint8_t  ubTypeV,
uint16_t  uwTimeV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
[in]ulIdV- PDO identifier
[in]ubDlcV- PDO DLC value
[in]ubTypeV- PDO transmission type
[in]uwTimeV- PDO timer
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function adds a new PDO to the CANopen Master. The PDO direction (TPDO or RPDO) is defined by the parameter ubPdoDirV. The parameter uwPdoNumV denotes the PDO number.

Example

void MyPdoSetup(void)
{
//---------------------------------------------------
// add first receive PDO, ID = 0x201
//
0x201, 8, ePDO_TYPE_EVENT_PROFILE, 0);
//---------------------------------------------------
// add two transmit PDOs, ID = 0x181 & 0x281
//
0x181, 8, ePDO_TYPE_EVENT_PROFILE, 0);
0x281, 8, ePDO_TYPE_EVENT_PROFILE, 0);
}

◆ ComPdoEnable()

ComStatus_tv ComPdoEnable ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t  ubEnableV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
[in]ubEnableV- Enable/Disable PDO
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

This function enables (ubEnableV = 1) or disables (ubEnableV = 0) the PDO with index uwPdoNumV. A PDO is disabled by default upon creation (see ComPdoConfig()).

◆ ComPdoEventReceive()

void ComPdoEventReceive ( uint8_t  ubNetV,
uint16_t  uwPdoNumV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number

The function is called by the CANopen Master stack upon reception of a Receive-PDO (RPDO). The Receive PDO has to be configured by ComPdoConfig() in advance.

◆ ComPdoEventTimeout()

void ComPdoEventTimeout ( uint8_t  ubNetV,
uint16_t  uwPdoNumV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number

The function is called by the CANopen Master stack when reception of a Receive-PDO (RPDO) times out. The Receive PDO has to be configured by ComPdoConfig() in advance.

◆ ComPdoGetCounter()

ComStatus_tv ComPdoGetCounter ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint32_t *  pulCounterV 
)
Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[out]pulCounterV- Pointer to counter variable
Returns
eCOM_ERR_NONE on success, negative ComErr_e value on failure

The function returns the number of PDOs that have been sent (for Transmit-PDOs) or received (for Receive-PDOs) by the CANopen Master.

◆ ComPdoGetData()

ComStatus_tv ComPdoGetData ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t *  pubDataV 
)

Get PDO data.

Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
[out]pubDataV- Pointer to data buffer
Returns
Value of enumeration ComErr_e

The function reads 8 bytes of data from the PDO defined by the parameter uwPdoNumV. The application must guarantee that pubDataV points to a buffer with at least 8 bytes.

◆ ComPdoGetDlc()

ComStatus_tv ComPdoGetDlc ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t *  pubDlcV 
)

Get DLC of a PDO.

Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
[out]pubDlcV- Pointer to buffer for data length code
Returns
Value of enumeration ComErr_e

The function reads the DLC of a PDO and saves it inside the location pointed by pubDlcV.

◆ ComPdoQueueClear()

ComStatus_tv ComPdoQueueClear ( uint8_t  ubNetV)
Parameters
[in]ubNetV- CANopen Network channel
Returns
Value of enumeration ComErr_e

The function removes all messages inside the PDO receive queue.

◆ ComPdoQueueCount()

ComStatus_tv ComPdoQueueCount ( uint8_t  ubNetV,
uint16_t *  puwCountV 
)
Parameters
[in]ubNetV- CANopen Network channel
[out]puwCountV- Number of messages present in the queue
Returns
Value of enumeration ComErr_e

The function retrieves the number of pending elements inside a PDO receive queue.

◆ ComPdoQueueDisable()

ComStatus_tv ComPdoQueueDisable ( uint8_t  ubNetV)
Parameters
[in]ubNetV- CANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComPdoQueueEnable()

The function disables the PDO receive queue on the selected CANopen network channel.

◆ ComPdoQueueEnable()

ComStatus_tv ComPdoQueueEnable ( uint8_t  ubNetV)
Parameters
[in]ubNetV- CANopen Network channel
Returns
Value of enumeration ComErr_e
See also
ComPdoQueueDisable()

The function enables the PDO receive queue on the selected CANopen network channel.

◆ ComPdoQueueFetch()

ComStatus_tv ComPdoQueueFetch ( uint8_t  ubNetV,
CpCanMsg_ts ptsCanMsgV 
)
Parameters
[in]ubNetV- CANopen Network channel
[out]ptsCanMsgV- Pointer to CAN message structure
Returns
Value of enumeration ComErr_e

The function fetches one CAN message from the PDO receive queue.

◆ ComPdoSetData()

ComStatus_tv ComPdoSetData ( uint8_t  ubNetV,
uint16_t  uwPdoNumV,
uint8_t  ubPdoDirV,
uint8_t *  pubDataV 
)

Set PDO Data.

Parameters
[in]ubNetV- CANopen Network channel
[in]uwPdoNumV- PDO number
[in]ubPdoDirV- PDO direction
[in]pubDataV- Pointer to data (an array of 8 byte)
Returns
Value of enumeration ComErr_e

The function writes 8 bytes of data to the PDO defined by the parameter uwPdoNumV.