CANpie FD
CAN programming interface environment - Version 3.08
Friends
QCanSocketCpFD Class Reference

Detailed Description

The QCanSocketCpFD class provides an interface between the CANpie FD core functions and the QCanSocket class. Hence it is possible to write applications using the C API of CANpie FD.

+ Inheritance diagram for QCanSocketCpFD:

Friends

CpStatus_tv CpCoreBitrate (CpPort_ts *ptsPortV, int32_t slNomBitRateV, int32_t slDatBitRateV)
 
CpStatus_tv CpCoreBufferConfig (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint32_t ulIdentifierV, uint32_t ulAcceptMaskV, uint8_t ubFormatV, uint8_t ubDirectionV)
 
CpStatus_tv CpCoreBufferGetData (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubDestDataV, uint8_t ubStartPosV, uint8_t ubSizeV)
 
CpStatus_tv CpCoreBufferGetDlc (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubDlcV)
 
CpStatus_tv CpCoreBufferRelease (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV)
 
CpStatus_tv CpCoreBufferSend (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV)
 
CpStatus_tv CpCoreBufferSetData (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubSrcDataV, uint8_t ubStartPosV, uint8_t ubSizeV)
 
CpStatus_tv CpCoreBufferSetDlc (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t ubDlcV)
 
CpStatus_tv CpCoreCanMode (CpPort_ts *ptsPortV, uint8_t ubModeV)
 
CpStatus_tv CpCoreCanState (CpPort_ts *ptsPortV, CpState_ts *ptsStateV)
 
CpStatus_tv CpCoreDriverInit (uint8_t ubPhyIfV, CpPort_ts *ptsPortV, uint8_t ubConfigV)
 
CpStatus_tv CpCoreDriverRelease (CpPort_ts *ptsPortV)
 
CpStatus_tv CpCoreFifoConfig (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpFifo_ts *ptsFifoV)
 
CpStatus_tv CpCoreFifoRead (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpCanMsg_ts *ptsCanMsgV, uint32_t *pulMsgCntV)
 
CpStatus_tv CpCoreFifoRelease (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV)
 
CpStatus_tv CpCoreFifoWrite (CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpCanMsg_ts *ptsCanMsgV, uint32_t *pulMsgCntV)
 
CpStatus_tv CpCoreHDI (CpPort_ts *ptsPortV, CpHdi_ts *ptsHdiV)
 
CpStatus_tv CpCoreStatistic (CpPort_ts *ptsPortV, CpStatistic_ts *ptsStatsV)
 

Additional Inherited Members

- Signals inherited from QCanSocket
void connected (void)
 
void disconnected (void)
 
void error (QAbstractSocket::SocketError teSockErrorV)
 
void readyRead (void)
 
- Public Member Functions inherited from QCanSocket
 QCanSocket (QObject *pclParentV=Q_NULLPTR)
 
bool connectNetwork (const CAN_Channel_e &teChannelR)
 
void disconnectNetwork (void)
 
QAbstractSocket::SocketError error () const
 
QString errorString () const
 
int32_t framesAvailable (void) const
 
bool isConnected (void) const
 
bool read (QCanFrame &clFrameR)
 
void setHostAddress (const QHostAddress clHostAddressV, const uint16_t uwPortV=QCAN_WEB_SOCKET_DEFAULT_PORT)
 
CAN_State_e state (void) const
 
QUuid uuid (void) const
 
QString uuidString (void) const
 
bool write (const QCanFrame &clFrameR)
 

Friends And Related Function Documentation

◆ CpCoreBitrate

CpStatus_tv CpCoreBitrate ( CpPort_ts *  ptsPortV,
int32_t  slNomBitRateV,
int32_t  slDatBitRateV 
)
friend

Set bit-rate of CAN controller.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]slNomBitRateVNominal Bit Timing selection
[in]slDatBitRateVData Bit Timing selection
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function initializes the bit timing registers of a CAN controller to pre-defined values. The values are defined by the enumeration CpBitrate_e. For a classical CAN controller (or if bit-rate switching is not required) the parameter slDatBitRateV is set to eCP_BITRATE_NONE.

◆ CpCoreBufferConfig

CpStatus_tv CpCoreBufferConfig ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
uint32_t  ulIdentifierV,
uint32_t  ulAcceptMaskV,
uint8_t  ubFormatV,
uint8_t  ubDirectionV 
)
friend

Initialise message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[in]ulIdentifierVIdentifier value
[in]ulAcceptMaskVAcceptance mask value
[in]ubFormatVMessage format
[in]ubDirectionVMessage direction
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.
See also
CpCoreBufferRelease()

This function allocates a message buffer in a CAN controller. The number of the message buffer inside the CAN controller is denoted via the parameter ubBufferIdxV. The first buffer starts at position eCP_BUFFER_1. The message buffer is allocated with the identifier value ulIdentifierV. If the buffer is used for reception (parameter ubDirectionV is eCP_BUFFER_DIR_RCV), the parameter ulAcceptMaskV is used for acceptance filtering.

The parameter ubFormatV can have the following values:

The following example shows the setup of a transmit buffer

void DemoTransmitBufferConfiguration(CpPort_ts * ptsCanPortV)
{
//----------------------------------------------------------------
// set message buffer 1 as transmit buffer for classic CAN frame
// with Standard Identifier 123h, DLC = 4
//
(uint32_t) 0x123,
CpCoreBufferSetDlc(ptsCanPortV, eCP_BUFFER_1, 4);
}

An allocated transmit buffer can be sent via the function CpCoreBufferSend().

The function initialises the DLC value of a message buffer to 0, a subsequent call of CpCoreBufferSetDlc() is necessary to change the default value.

◆ CpCoreBufferGetData

CpStatus_tv CpCoreBufferGetData ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
uint8_t *  pubDestDataV,
uint8_t  ubStartPosV,
uint8_t  ubSizeV 
)
friend

Get data from message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[out]pubDestDataVPointer to destination data buffer
[in]ubStartPosVArray start position
[in]ubSizeVNumber of bytes to read
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

The functions copies ubSizeV data bytes from the CAN message buffer defined by ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The parameter ubStartPosV denotes the start position, the first data byte is at position 0. The destination buffer (pointer pubDestDataV) must have sufficient space for the data. The buffer has to be configured by CpCoreBufferConfig() in advance.

◆ CpCoreBufferGetDlc

CpStatus_tv CpCoreBufferGetDlc ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
uint8_t *  pubDlcV 
)
friend

Get DLC of specified buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[out]pubDlcVData Length Code
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function retrieves the Data Length Code (DLC) of the selected buffer ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The parameter pubDlcV is a pointer to a memory location where the function will store the DLC value on success. The buffer has to be configured by CpCoreBufferConfig() in advance.

◆ CpCoreBufferRelease

CpStatus_tv CpCoreBufferRelease ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV 
)
friend

Release message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.
See also
CpCoreBufferConfig()

The function releases the allocated message buffer specified by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. Both - reception and transmission - will be disabled on the specified message buffer afterwards.

◆ CpCoreBufferSend

CpStatus_tv CpCoreBufferSend ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV 
)
friend

Send message from message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVIndex of message buffer
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function transmits a message from the specified message buffer ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The message buffer has to be configured as transmit buffer (eCP_BUFFER_DIR_TRM) by a call to CpCoreBufferConfig() in advance. A transmission request on a receive buffer will fail with the return code eCP_ERR_INIT_FAIL.

◆ CpCoreBufferSetData

CpStatus_tv CpCoreBufferSetData ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
uint8_t *  pubSrcDataV,
uint8_t  ubStartPosV,
uint8_t  ubSizeV 
)
friend

Set data of message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[in]pubSrcDataVPointer to source data buffer
[in]ubStartPosVArray start position
[in]ubSizeVNumber of bytes to write
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function copies ubSizeV data bytes from the source buffer (pointer pubSrcDataV) into the message buffer defined by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The parameter ubStartPosV denotes the start position, the first data byte is at position 0. The message buffer has to be configured by CpCoreBufferConfig() in advance.

The following example demonstrates the access to the data bytes of a CAN message:

uint8_t aubDataT[8]; // buffer for 8 bytes
aubDataT[0] = 0x11; // byte 0: set to 11hex
aubDataT[1] = 0x22; // byte 1: set to 22hex
//--- copy the stuff to message buffer 1 ---------------
CpCoreBufferSetData(ptsCanPortS, eCP_BUFFER_1, &aubDataT, 0, 2);
//--- send this message out ----------------------------

◆ CpCoreBufferSetDlc

CpStatus_tv CpCoreBufferSetDlc ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
uint8_t  ubDlcV 
)
friend

Set DLC of specified buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[in]ubDlcVData Length Code
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function sets the Data Length Code (DLC) of the specified message buffer ubBufferIdxV. The DLC value ubDlcV must be in the range from 0 to 8 for Classical CAN frames and 0 to 15 for ISO CAN FD frames. An invalid DLC value is rejected with the return value eCP_ERR_CAN_DLC. The message buffer has to be configured by a call to CpCoreBufferConfig() in advance.

◆ CpCoreCanMode

CpStatus_tv CpCoreCanMode ( CpPort_ts *  ptsPortV,
uint8_t  ubModeV 
)
friend

Set state of CAN controller.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubModeVMode selection
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function changes the operating mode of the CAN controller FSA. Possible values for the parameter ubModeV are defined in the CpMode_e enumeration. At least the modes eCP_MODE_INIT and eCP_MODE_OPERATION shall be supported. Other modes depend on the capabilities of the CAN controller.

CAN controller FSA

◆ CpCoreCanState

CpStatus_tv CpCoreCanState ( CpPort_ts *  ptsPortV,
CpState_ts ptsStateV 
)
friend

Retrieve state of CAN controller.

Parameters
[in]ptsPortVPointer to CAN port structure
[out]ptsStateVPointer to CAN state structure
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function retrieves the present state of the CAN controller. The parameter ptsStateV is a pointer to a memory location where the function will store the state. The value of the structure element CpState_ts::ubCanErrState is defined by the CpState_e enumeration. The value of the structure element CpState_ts::ubCanErrType is defined by the CpErrType_e enumeration.

◆ CpCoreDriverInit

CpStatus_tv CpCoreDriverInit ( uint8_t  ubPhyIfV,
CpPort_ts *  ptsPortV,
uint8_t  ubConfigV 
)
friend

Initialise the CAN driver.

Parameters
[in]ubPhyIfVCAN channel of the hardware
[out]ptsPortVPointer to CAN port structure
[in]ubConfigVThis parameter is reserved for future enhancement
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.
See also
CpCoreDriverRelease()

The functions opens the physical CAN interface defined by the parameter ubPhyIfV. The value for ubPhyIfV is taken from the enumeration CpChannel_e. The function sets up the field members of the CAN port structure CpPort_ts. The parameter ptsPortV is a pointer to a memory location where structure CpPort_ts is stored. An opened CAN port must be closed via the CpCoreDriverRelease() function.

◆ CpCoreDriverRelease

CpStatus_tv CpCoreDriverRelease ( CpPort_ts *  ptsPortV)
friend

Release the CAN driver.

Parameters
[in]ptsPortVPointer to CAN port structure
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.
See also
CpCoreDriverInit()

The function closes a CAN port. The parameter ptsPortV is a pointer to a memory location where structure CpPort_ts is stored. The implementation of this function is dependent on the operating system. Typical tasks might be:

  • clear the interrupt vector / routine
  • close all open paths to the hardware

◆ CpCoreFifoConfig

CpStatus_tv CpCoreFifoConfig ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
CpFifo_ts ptsFifoV 
)
friend

Assign FIFO to message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[in]ptsFifoVPointer to FIFO structure
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function assigns a FIFO to a message buffer defined by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The buffer has to be configured by CpCoreBufferConfig() in advance. The parameter ptsFifoV is a pointer to a memory location where a FIFO has been initialized using the CpFifoInit() function.

The following example shows the configuration of a receive FIFO

#define FIFO_RCV_SIZE 32
static CpFifo_ts tsFifoRcvS;
static CpCanMsg_ts atsCanMsgRcvS[FIFO_RCV_SIZE];
//----------------------------------------------------------------------------//
// DemoFifoConfig() //
// //
//----------------------------------------------------------------------------//
void DemoFifoConfig(CpPort_ts * ptsCanPortV)
{
//------------------------------------------------------
// set message buffer 2 as receive buffer for classic
// CAN frame with identifier 180h .. 18Fh
//
(uint32_t) 0x180,
(uint32_t) 0x7F0, // mask
CpFifoInit(&tsFifoRcvS, &atsCanMsgRcvS[0], FIFO_RCV_SIZE);
CpCoreFifoConfig(ptsCanPortV, eCP_BUFFER_2, &tsFifoRcvS);
}

◆ CpCoreFifoRead

CpStatus_tv CpCoreFifoRead ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
CpCanMsg_ts ptsCanMsgV,
uint32_t *  pulMsgCntV 
)
friend

Read a CAN message from FIFO.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[out]ptsCanMsgVPointer to a CAN message structure
[in,out]pulMsgCntVPointer to message count variable
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function reads CAN messages from a receive FIFO defined by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The FIFO has to be configured by CpCoreFifoConfig() in advance. The parameter ptsCanMsgV is a pointer to the application buffer as array of CpCanMsg_ts objects to store the received CAN messages. The parameter pulMsgCntV is a pointer to a memory location which has to be initialized before the call to the size of the buffer referenced by ptsCanMsgV as multiple of CpCanMsg_ts objects. Upon return, the driver has stored the number of messages copied into the application buffer into this parameter.

The following example shows a read operation from a receive FIFO

void DemoFifoRead(CpPort_ts * ptsCanPortV)
{
CpCanMsg_ts tsCanMsgReadT;
uint32_t ulMsgCntT;
//------------------------------------------------------
// try to read one CAN message
//
ulMsgCntT = 1;
&tsCanMsgReadT,
&ulMsgCntT);
}

◆ CpCoreFifoRelease

CpStatus_tv CpCoreFifoRelease ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV 
)
friend

Release FIFO from message buffer.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function releases an assigned FIFO from a message buffer defined by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The FIFO has to be configured by CpCoreFifoConfig() in advance.

◆ CpCoreFifoWrite

CpStatus_tv CpCoreFifoWrite ( CpPort_ts *  ptsPortV,
uint8_t  ubBufferIdxV,
CpCanMsg_ts ptsCanMsgV,
uint32_t *  pulMsgCntV 
)
friend

Transmit a CAN message.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ubBufferIdxVBuffer number
[in]ptsCanMsgVPointer to a CAN message structure
[in,out]pulMsgCntVPointer to message count variable
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function writes CAN messages to a transmit FIFO defined by the parameter ubBufferIdxV. The first message buffer starts at the index eCP_BUFFER_1. The FIFO has to be configured by CpCoreFifoConfig() in advance. The parameter ptsCanMsgV is a pointer to the application buffer as array of CpCanMsg_ts objects which contain the CAN messages that should be transmitted. The parameter pulMsgCntV is a pointer to a memory location which has to be initialized before the call to the size of the buffer referenced by ptsCanMsgV as multiple of CpCanMsg_ts objects. Upon return, the driver has stored the number of messages transmitted successfully into this parameter.

◆ CpCoreHDI

CpStatus_tv CpCoreHDI ( CpPort_ts *  ptsPortV,
CpHdi_ts ptsHdiV 
)
friend

Get hardware description information.

Parameters
[in]ptsPortVPointer to CAN port structure
[out]ptsHdiVPointer to the Hardware Description Interface structure (CpHdi_ts)
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function retrieves information about the CAN interface. The parameter ptsHdiV is a pointer to a memory location where the function will store the information.

◆ CpCoreStatistic

CpStatus_tv CpCoreStatistic ( CpPort_ts *  ptsPortV,
CpStatistic_ts ptsStatsV 
)
friend

Read CAN controller statistics.

Parameters
[in]ptsPortVPointer to CAN port structure
[in]ptsStatsVPointer to statistic data structure
Returns
Error code is defined by the CpErr_e enumeration. If no error occurred, the function will return the value eCP_ERR_NONE.

This function copies CAN statistic information to the structure pointed by ptsStatsV.

QCanSocketCpFD::CpCoreBufferConfig
friend CpStatus_tv CpCoreBufferConfig(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint32_t ulIdentifierV, uint32_t ulAcceptMaskV, uint8_t ubFormatV, uint8_t ubDirectionV)
Initialise message buffer.
QCanSocketCpFD::CpCoreBufferSetData
friend CpStatus_tv CpCoreBufferSetData(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t *pubSrcDataV, uint8_t ubStartPosV, uint8_t ubSizeV)
Set data of message buffer.
QCanSocketCpFD::CpCoreFifoConfig
friend CpStatus_tv CpCoreFifoConfig(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpFifo_ts *ptsFifoV)
Assign FIFO to message buffer.
QCanSocketCpFD::CpCoreBufferSetDlc
friend CpStatus_tv CpCoreBufferSetDlc(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, uint8_t ubDlcV)
Set DLC of specified buffer.
eCP_BUFFER_1
@ eCP_BUFFER_1
Definition: canpie.h:898
CP_MASK_STD_FRAME
#define CP_MASK_STD_FRAME
Definition: canpie.h:297
eCP_BUFFER_DIR_RCV
@ eCP_BUFFER_DIR_RCV
Definition: canpie.h:937
CpFifo_s
Administration variables of a CAN message FIFO.
Definition: cp_fifo.h:89
CP_MSG_FORMAT_CBFF
#define CP_MSG_FORMAT_CBFF
Definition: canpie.h:414
QCanSocketCpFD::CpCoreFifoRead
friend CpStatus_tv CpCoreFifoRead(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV, CpCanMsg_ts *ptsCanMsgV, uint32_t *pulMsgCntV)
Read a CAN message from FIFO.
CpCanMsg_s
CAN message structure.
Definition: canpie.h:1003
CpFifoInit
void CpFifoInit(CpFifo_ts *ptsFifoV, CpCanMsg_ts *ptsCanMsgV, uint32_t ulSizeV)
eCP_BUFFER_2
@ eCP_BUFFER_2
Definition: canpie.h:901
eCP_BUFFER_DIR_TRM
@ eCP_BUFFER_DIR_TRM
Definition: canpie.h:940
QCanSocketCpFD::CpCoreBufferSend
friend CpStatus_tv CpCoreBufferSend(CpPort_ts *ptsPortV, uint8_t ubBufferIdxV)
Send message from message buffer.