![]() |
CANopen FD Master Library
Making your systems precise, reliable and high-quality - 5.10.01
|
Functions | |
ComStatus_tv | ComJ1939_PgnConfig (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint32_t ulPgnV, uint8_t ubPriorityV, uint8_t ubAddrV, uint16_t uwTimeV) |
ComStatus_tv | ComJ1939_PgnEnable (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint8_t ubEnableV) |
ComStatus_tv | ComJ1939_PgnGetCounter (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint32_t *pulCounterV) |
ComStatus_tv | ComJ1939_PgnGetData (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint8_t *pubSrcAddrV, uint8_t *pubDataV, uint16_t *puwSizeV) |
uint8_t | ComJ1939_PgnGetDestination (uint32_t ulIdentifierV) |
ComStatus_tv | ComJ1939_PgnGetSize (uint8_t ubNetV, uint16_t uwPgnIdxV, uint16_t *puwSizeV) |
uint8_t | ComJ1939_PgnGetSource (uint32_t ulIdentifierV) |
ComStatus_tv | ComJ1939_PgnIsEnabled (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV) |
ComStatus_tv | ComJ1939_PgnRequest (uint8_t ubNetV, uint32_t ulPgnV, uint8_t ubDestAddrV) |
ComStatus_tv | ComJ1939_PgnSendAsync (uint8_t ubNetV, uint16_t uwPgnIdxV) |
ComStatus_tv | ComJ1939_PgnSetData (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint8_t *pubDataV, uint16_t uwSizeV) |
ComStatus_tv | ComJ1939_PgnSetTimer (uint8_t ubNetV, uint16_t uwPgnIdxV, uint8_t ubPgnDirV, uint16_t uwTimeV) |
The SAE J1939 module is an optional function for the CANopen Master protocol stack. The J1939 support is enabled by setting the value eCOM_MODE_J1939 for parameter ulModeV inside the function ComMgrInit().
The following example depicts the initialisation:
ComStatus_tv ComJ1939_PgnConfig | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint32_t | ulPgnV, | ||
uint8_t | ubPriorityV, | ||
uint8_t | ubAddrV, | ||
uint16_t | uwTimeV | ||
) |
Add a PGN.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
ulPgnV | - PGN value |
ubPriorityV | - PGN priority |
ubAddrV | - address information |
uwTimeV | - PGN timer |
This function adds a new PGN to the CANopen Master. The PGN type is defined by setting the definition ePGN_DIR_RCV for Receive-PGNs and ePGN_DIR_TRM for Transmit-PGNs to the parameter ubPgnDirV. The PGN index uwPgnIdxV starts at 0.
The parameter ubAddrV is evaluated for Receive-PGNs: only PDUs from ECUs with address ubAddrV are evaluated. In order to receive messages from all ECUs in the network on the defined index uwPgnIdxV the address parameter must be set to J1939_ADDR_BROADCAST.
Example
ComStatus_tv ComJ1939_PgnEnable | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint8_t | ubEnableV | ||
) |
Enable PGN.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
ubEnableV | - Enable/Disable PGN |
This function enables (ubEnableV = 1) or disables (ubEnableV = 0) the PGN with index uwPgnIdxV. A PGN is disabled by default upon creation (see ComJ1939_PgnConfig()).
ComStatus_tv ComJ1939_PgnGetCounter | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint32_t * | pulCounterV | ||
) |
Get PGN counter.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
pulCounterV | - Pointer to counter variable |
The function returns the number of PGNs that have been sent (for Transmit-PGNs) or received (for Receive-PGNs) by the CANopen Master.
ComStatus_tv ComJ1939_PgnGetData | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint8_t * | pubSrcAddrV, | ||
uint8_t * | pubDataV, | ||
uint16_t * | puwSizeV | ||
) |
Get PGN data.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
pubSrcAddrV | - Pointer to ECU source address |
pubDataV | - Pointer to data buffer |
puwSizeV | - Pointer to size variable |
The function reads data from the PGN defined by the parameter uwPgnIdxV. The application must guarantee that pubDataV points to a buffer with sufficient size (maximum 1785 bytes).
uint8_t ComJ1939_PgnGetDestination | ( | uint32_t | ulIdentifierV | ) |
Get destination address of a PDU identifier.
ulIdentifierV | - identifier value |
The function calculates the destination address of the PDU identifier given by parameter ulIdentifierV. For a PDU2 type message the function will return the broadcast address (J1939_ADDR_BROADCAST).
ComStatus_tv ComJ1939_PgnGetSize | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint16_t * | puwSizeV | ||
) |
Get size of a PGN.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
puwSizeV | - Pointer to buffer for size |
The function reads the size of a PGN.
uint8_t ComJ1939_PgnGetSource | ( | uint32_t | ulIdentifierV | ) |
Get source address of a PDU identifier.
ulIdentifierV | - identifier value |
The function calculates the source address of the PDU identifier given by parameter ulIdentifierV.
ComStatus_tv ComJ1939_PgnIsEnabled | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV | ||
) |
Check PGN.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
ComStatus_tv ComJ1939_PgnRequest | ( | uint8_t | ubNetV, |
uint32_t | ulPgnV, | ||
uint8_t | ubDestAddrV | ||
) |
Request PGN.
ubNetV | - Network channel |
ulPgnV | - PGN value |
ubDestAddrV | - ECU destination address |
This function sends a PGN request message to an ECU with address ubDestAddrV. The value for ubDestAddrV can be set to #J1939_ADDR_BROADCAST in order to sent the request to all ECUs present in the network.
ComStatus_tv ComJ1939_PgnSendAsync | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV | ||
) |
Send a PGN.
ubNetV | - Network channel |
uwPgnIdxV | - PDO index |
This function sends a PGN defined by the index uwPgnIdxV asynchronous.
ComStatus_tv ComJ1939_PgnSetData | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint8_t * | pubDataV, | ||
uint16_t | uwSizeV | ||
) |
Set PGN Data.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
pubDataV | - Pointer to data |
uwSizeV | - Number of bytes |
ComStatus_tv ComJ1939_PgnSetTimer | ( | uint8_t | ubNetV, |
uint16_t | uwPgnIdxV, | ||
uint8_t | ubPgnDirV, | ||
uint16_t | uwTimeV | ||
) |
Set PGN timer.
ubNetV | - Network channel |
uwPgnIdxV | - PGN index |
ubPgnDirV | - PGN direction |
uwTimeV | - Time value |