cp_msg.h File Reference
CANpie message access.
More...
Detailed Description
In order to create small and fast code, CANpie supplies a set of macros to access the CAN message structure (_TsCpCanMsg). These macros can be used instead of the functions defined in the cp_msg.h header file. However keep in mind that macros can't be used to check for value ranges or parameter consistence. Usage of macros is enabled via the symbol CP_CAN_MSG_MACRO.
Example
Function Documentation
Clear message structure.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
This macro sets the identifier field and the flags field of a CAN message structure to 0. It is recommended to use this function when a message structure is assigned in memory.
Clear RTR bit.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- See also:
- CpMsgSetRemote()
This function clears the Remote Transmission bit (RTR).
_U08 CpMsgGetData |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_U08 |
ubPosV | |
|
) |
| | |
Get Data.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| ubPosV | Zero based index of byte position |
- Returns:
- Value of data at position ubPosV
This functions retrieves the data of a CAN message. The parameter
ubPosV
must be within the range 0 .. 7. Please note that the macro implementation does not check the value range of the parameter
ubPosV
.
Get Data Length Code.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- Returns:
- Data Length Code (DLC) of CAN message
This function retrieves the data length code (DLC) of a CAN message. The return value range is between 0 and 8.
Get 29 Bit Identifier Value.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- Returns:
- Extended Identifier value
- See also:
- CpMsgGetStdId()
This function retrieves the value for the identifier of an extended frame (CAN 2.0B). The frame format of the CAN message can be tested with the
CpMsgIsExtended() function.
Get 11 Bit Identifier Value.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- Returns:
- Standard Identifier value
- See also:
- CpMsgGetExtId()
This macro retrieves the value for the identifier of an standard frame (CAN 2.0A). The frame format of the CAN message can be tested with the
CpMsgIsExtended() function.
Check the frame type.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- Returns:
- 0 for CAN 2.0A, 1 for CAN 2.0B
This function checks the frame type. If the frame is CAN 2.0A (Standard Frame), the value 0 is returned. If the frame is CAN 2.0B (Extended Frame), the value 1 is returned.
Check for remote frame.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
- Returns:
- 0 for data frame, 1 for remote frame
This function checks if the Remote Transmission bit (RTR) is set. If the RTR bit is set, the function will return 1, otherwise 0.
void CpMsgSetData |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_U08 |
ubPosV, |
|
|
_U08 |
ubValueV | |
|
) |
| | |
Set Data.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| ubPosV | Zero based index of byte position |
| ubValueV | Value of data byte in CAN message |
This function sets the data in a CAN message. The parameter
ubPosV
must be within the range 0 .. 7. Please note that the macro implementation does not check the value range of the parameter
ubPosV
.
void CpMsgSetDlc |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_U08 |
ubDlcV | |
|
) |
| | |
Set Data Length Code.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| ubDlcV | Data Length Code |
This function sets the Data Length Code (DLC) of a CAN message. The parameter ubDlcV must be within the range from 0..8. Please note that the macro implementation does not check the value range of the parameter
ubDlcV
.
void CpMsgSetExtId |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_U32 |
ulExtIdV | |
|
) |
| | |
Set 29 Bit Identifier Value.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| ulExtIdV | Identifier value |
- See also:
- CpMsgSetStdFrame()
This function sets the identifer value for an Extended Frame (CAN 2.0B) and marks the frame format as accordingly. The value of
ulExtIdV
is limited to
CP_MASK_EXT_FRAME.
Set RTR bit.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
This function sets the Remote Transmission bit (RTR).
void CpMsgSetStdId |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_U16 |
uwStdIdV | |
|
) |
| | |
Set 11 Bit Identifier Value.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| uwStdIdV | Identifier value |
- See also:
- CpMsgSetExtFrame()
This function sets the identifer value for a Standard frame (CAN 2.0A). The value of
uwStdIdV
is limited to
CP_MASK_STD_FRAME.
void CpMsgSetTime |
( |
_TsCpCanMsg * |
ptsCanMsgV, |
|
|
_TsCpTime * |
ptsTimeV | |
|
) |
| | |
Set timestamp value.
- Parameters:
-
| ptsCanMsgV | Pointer to a _TsCpCanMsg message |
| ptsTimeV | Pointer to timestamp structure |
This function sets the timestamp value for a CAN frame.