Refs #460. Added length parameter to the XCP packet reception functions.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@424 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2018-02-09 16:59:41 +00:00
parent 817212b60f
commit 6f80eb072f
36 changed files with 139 additions and 51 deletions

View File

@ -246,12 +246,14 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId; blt_int32u rxMsgId;
blt_int8u rxMsgDlc;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
/* check if a new message was received */ /* check if a new message was received */
@ -268,6 +270,13 @@ blt_bool CanReceivePacket(blt_int8u *data)
/* see if this is the message identifier that we are interested in */ /* see if this is the message identifier that we are interested in */
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID) if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
{ {
/* store the message data length */
rxMsgDlc = ((blt_int8u)(CAN1RFS >> 16)) & 0x0Fu;
if (rxMsgDlc > 8)
{
rxMsgDlc = 8;
}
*len = rxMsgDlc;
/* store the message data */ /* store the message data */
data[0] = (blt_int8u)CAN1RDA; data[0] = (blt_int8u)CAN1RDA;
data[1] = (blt_int8u)(CAN1RDA >> 8); data[1] = (blt_int8u)(CAN1RDA >> 8);

View File

@ -165,10 +165,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -208,6 +209,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -222,10 +222,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
CanRxMsg rxMsg; CanRxMsg rxMsg;
blt_int8u byteIdx; blt_int8u byteIdx;
@ -252,6 +253,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
/* is the identifier a match to the bootloader reception message identifier? */ /* is the identifier a match to the bootloader reception message identifier? */
if (canIdMatched == BLT_TRUE) if (canIdMatched == BLT_TRUE)
{ {
*len = rxMsg.DLC;
for (byteIdx=0; byteIdx<rxMsg.DLC; byteIdx++) for (byteIdx=0; byteIdx<rxMsg.DLC; byteIdx++)
{ {
data[byteIdx] = rxMsg.Data[byteIdx]; data[byteIdx] = rxMsg.Data[byteIdx];

View File

@ -145,10 +145,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -188,6 +189,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -241,10 +241,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int8u byteIdx; blt_int8u byteIdx;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -255,6 +256,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
/* read out and process the newly received data */ /* read out and process the newly received data */
if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS) if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS)
{ {
*len = receiveMsgObj.can_data_length;
for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++) for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++)
{ {
data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx]; data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx];

View File

@ -135,10 +135,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -178,6 +179,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -126,10 +126,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -169,6 +170,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -198,10 +198,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u status; blt_int32u status;
tCANMsgObject msgObject; tCANMsgObject msgObject;
@ -217,6 +218,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
/* read the message data */ /* read the message data */
msgObject.pucMsgData = data; msgObject.pucMsgData = data;
CANMessageGet(CAN0_BASE, CAN_RX_MSGOBJECT_IDX+1, &msgObject, true); CANMessageGet(CAN0_BASE, CAN_RX_MSGOBJECT_IDX+1, &msgObject, true);
*len = msgObject.ulMsgLen;
/* message was successfully received */ /* message was successfully received */
return BLT_TRUE; return BLT_TRUE;
} /*** end of CanReceivePacket ***/ } /*** end of CanReceivePacket ***/

View File

@ -109,10 +109,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -152,6 +153,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -334,10 +334,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId; blt_int32u rxMsgId;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -361,6 +362,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID) if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
{ {
result = BLT_TRUE; result = BLT_TRUE;
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
/* store the received packet data */ /* store the received packet data */
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR; data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8); data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);

View File

@ -159,10 +159,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -202,6 +203,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -171,10 +171,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UsbReceivePacket(blt_int8u *data) blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -214,7 +215,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -365,10 +365,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId; blt_int32u rxMsgId;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -392,6 +393,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID) if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
{ {
result = BLT_TRUE; result = BLT_TRUE;
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
/* store the received packet data */ /* store the received packet data */
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR; data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8); data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);

View File

@ -135,10 +135,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -178,6 +179,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -269,10 +269,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID; blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -314,6 +315,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
{ {
data[byteIdx] = canHandle.pRxMsg->Data[byteIdx]; data[byteIdx] = canHandle.pRxMsg->Data[byteIdx];
} }
*len = canHandle.pRxMsg->DLC;
/* update the return value to indicate that new packet data was received. */ /* update the return value to indicate that new packet data was received. */
result = BLT_TRUE; result = BLT_TRUE;
} }

View File

@ -125,10 +125,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -168,6 +169,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -365,10 +365,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId; blt_int32u rxMsgId;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -392,6 +393,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID) if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
{ {
result = BLT_TRUE; result = BLT_TRUE;
*len = ((blt_int8u)(CANx->sFIFOMailBox[0].RDTR)) & 0x0fu;
/* store the received packet data */ /* store the received packet data */
data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR; data[0] = (blt_int8u)0xFF & CANx->sFIFOMailBox[0].RDLR;
data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8); data[1] = (blt_int8u)0xFF & (CANx->sFIFOMailBox[0].RDLR >> 8);

View File

@ -136,10 +136,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -179,6 +180,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -172,10 +172,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UsbReceivePacket(blt_int8u *data) blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -215,7 +216,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -278,10 +278,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID; blt_int32u rxMsgId = BOOT_COM_CAN_RX_MSG_ID;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -302,7 +303,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
} }
else else
{ {
/* negate the ID-type bit */ /* negate the ID-type bit. */
rxMsgId &= ~0x80000000; rxMsgId &= ~0x80000000;
/* was an 29-bit CAN message received that matches? */ /* was an 29-bit CAN message received that matches? */
if ( (rxMsgHeader.ExtId == rxMsgId) && if ( (rxMsgHeader.ExtId == rxMsgId) &&
@ -313,6 +314,11 @@ blt_bool CanReceivePacket(blt_int8u *data)
} }
} }
} }
/* store the data length. */
if (result == BLT_TRUE)
{
*len = rxMsgHeader.DLC;
}
/* Give the result back to the caller. */ /* Give the result back to the caller. */
return result; return result;
} /*** end of CanReceivePacket ***/ } /*** end of CanReceivePacket ***/

View File

@ -133,10 +133,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -176,6 +177,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -111,10 +111,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -154,6 +155,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -186,10 +186,11 @@ void UsbTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UsbReceivePacket(blt_int8u *data) blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_USB_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -229,7 +230,8 @@ blt_bool UsbReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -245,10 +245,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int8u byteIdx; blt_int8u byteIdx;
blt_bool result = BLT_FALSE; blt_bool result = BLT_FALSE;
@ -259,6 +260,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
/* read out and process the newly received data */ /* read out and process the newly received data */
if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS) if (XMC_CAN_MO_ReceiveData(&receiveMsgObj) == XMC_CAN_STATUS_SUCCESS)
{ {
*len = receiveMsgObj.can_data_length;
for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++) for (byteIdx=0; byteIdx<receiveMsgObj.can_data_length; byteIdx++)
{ {
data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx]; data[byteIdx] = receiveMsgObj.can_data_byte[byteIdx];

View File

@ -137,10 +137,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -180,6 +181,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -354,10 +354,11 @@ void CanTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE is a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool CanReceivePacket(blt_int8u *data) blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
blt_int32u rxMsgId; blt_int32u rxMsgId;
blt_int8u rxMsgLen; blt_int8u rxMsgLen;
@ -391,6 +392,7 @@ blt_bool CanReceivePacket(blt_int8u *data)
{ {
data[byte_idx] = CAN->rxSlot.dsr[byte_idx]; data[byte_idx] = CAN->rxSlot.dsr[byte_idx];
} }
*len = rxMsgLen;
} }
/* release the receive object by clearing the rx flag */ /* release the receive object by clearing the rx flag */
CAN->crflg &= RXF_BIT; CAN->crflg &= RXF_BIT;

View File

@ -154,10 +154,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -197,6 +198,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -163,10 +163,11 @@ void UartTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool UartReceivePacket(blt_int8u *data) blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */ static blt_int8u xcpCtoReqPacket[BOOT_COM_UART_RX_MAX_DATA+1]; /* one extra for length */
static blt_int8u xcpCtoRxLength; static blt_int8u xcpCtoRxLength;
@ -206,6 +207,8 @@ blt_bool UartReceivePacket(blt_int8u *data)
CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength); CpuMemCopy((blt_int32u)data, (blt_int32u)&xcpCtoReqPacket[1], xcpCtoRxLength);
/* done with cto packet reception */ /* done with cto packet reception */
xcpCtoRxInProgress = BLT_FALSE; xcpCtoRxInProgress = BLT_FALSE;
/* set the packet length */
*len = xcpCtoRxLength;
/* packet reception complete */ /* packet reception complete */
return BLT_TRUE; return BLT_TRUE;
} }

View File

@ -34,7 +34,7 @@
****************************************************************************************/ ****************************************************************************************/
void CanInit(void); void CanInit(void);
void CanTransmitPacket(blt_int8u *data, blt_int8u len); void CanTransmitPacket(blt_int8u *data, blt_int8u len);
blt_bool CanReceivePacket(blt_int8u *data); blt_bool CanReceivePacket(blt_int8u *data, blt_int8u *len);
#endif /* BOOT_COM_CAN_ENABLE > 0 */ #endif /* BOOT_COM_CAN_ENABLE > 0 */

View File

@ -97,43 +97,44 @@ void ComInit(void)
****************************************************************************************/ ****************************************************************************************/
void ComTask(void) void ComTask(void)
{ {
blt_int8u xcpPacketLen;
/* make xcpCtoReqPacket static for runtime efficiency */ /* make xcpCtoReqPacket static for runtime efficiency */
static blt_int8u xcpCtoReqPacket[BOOT_COM_RX_MAX_DATA]; static blt_int8u xcpCtoReqPacket[BOOT_COM_RX_MAX_DATA];
#if (BOOT_COM_CAN_ENABLE > 0) #if (BOOT_COM_CAN_ENABLE > 0)
if (CanReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE) if (CanReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
{ {
/* make this the active interface */ /* make this the active interface */
comActiveInterface = COM_IF_CAN; comActiveInterface = COM_IF_CAN;
/* process packet */ /* process packet */
XcpPacketReceived(&xcpCtoReqPacket[0]); XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
} }
#endif #endif
#if (BOOT_COM_UART_ENABLE > 0) #if (BOOT_COM_UART_ENABLE > 0)
if (UartReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE) if (UartReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
{ {
/* make this the active interface */ /* make this the active interface */
comActiveInterface = COM_IF_UART; comActiveInterface = COM_IF_UART;
/* process packet */ /* process packet */
XcpPacketReceived(&xcpCtoReqPacket[0]); XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
} }
#endif #endif
#if (BOOT_COM_USB_ENABLE > 0) #if (BOOT_COM_USB_ENABLE > 0)
if (UsbReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE) if (UsbReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
{ {
/* make this the active interface */ /* make this the active interface */
comActiveInterface = COM_IF_USB; comActiveInterface = COM_IF_USB;
/* process packet */ /* process packet */
XcpPacketReceived(&xcpCtoReqPacket[0]); XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
} }
#endif #endif
#if (BOOT_COM_NET_ENABLE > 0) #if (BOOT_COM_NET_ENABLE > 0)
if (NetReceivePacket(&xcpCtoReqPacket[0]) == BLT_TRUE) if (NetReceivePacket(&xcpCtoReqPacket[0], &xcpPacketLen) == BLT_TRUE)
{ {
/* make this the active interface */ /* make this the active interface */
comActiveInterface = COM_IF_NET; comActiveInterface = COM_IF_NET;
/* process packet */ /* process packet */
XcpPacketReceived(&xcpCtoReqPacket[0]); XcpPacketReceived(&xcpCtoReqPacket[0], xcpPacketLen);
} }
#endif #endif
} /*** end of ComTask ***/ } /*** end of ComTask ***/

View File

@ -171,10 +171,11 @@ void NetTransmitPacket(blt_int8u *data, blt_int8u len)
/************************************************************************************//** /************************************************************************************//**
** \brief Receives a communication interface packet if one is present. ** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored. ** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise. ** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
** **
****************************************************************************************/ ****************************************************************************************/
blt_bool NetReceivePacket(blt_int8u *data) blt_bool NetReceivePacket(blt_int8u *data, blt_int8u *len)
{ {
/* run the TCP/IP server task function, which will handle the reception and /* run the TCP/IP server task function, which will handle the reception and
* transmission of XCP packets * transmission of XCP packets
@ -238,7 +239,7 @@ void NetApp(void)
s->dto_len = 0; s->dto_len = 0;
/* the first 4 bytes contain a counter value in which we are not really interested */ /* the first 4 bytes contain a counter value in which we are not really interested */
newDataPtr = uip_appdata; newDataPtr = uip_appdata;
XcpPacketReceived(&newDataPtr[4]); XcpPacketReceived(&newDataPtr[4], (blt_int8u)(uip_datalen() - 4));
} }
} /*** end of NetApp ***/ } /*** end of NetApp ***/

View File

@ -58,7 +58,7 @@ typedef struct net_state
void NetInit(void); void NetInit(void);
void NetApp(void); void NetApp(void);
void NetTransmitPacket(blt_int8u *data, blt_int8u len); void NetTransmitPacket(blt_int8u *data, blt_int8u len);
blt_bool NetReceivePacket(blt_int8u *data); blt_bool NetReceivePacket(blt_int8u *data, blt_int8u *len);
#else /* BOOT_COM_NET_ENABLE > 0 */ #else /* BOOT_COM_NET_ENABLE > 0 */
typedef struct net_state typedef struct net_state

View File

@ -34,7 +34,7 @@
****************************************************************************************/ ****************************************************************************************/
void UartInit(void); void UartInit(void);
void UartTransmitPacket(blt_int8u *data, blt_int8u len); void UartTransmitPacket(blt_int8u *data, blt_int8u len);
blt_bool UartReceivePacket(blt_int8u *data); blt_bool UartReceivePacket(blt_int8u *data, blt_int8u *len);
#endif /* BOOT_COM_UART_ENABLE > 0 */ #endif /* BOOT_COM_UART_ENABLE > 0 */

View File

@ -35,7 +35,7 @@
void UsbInit(void); void UsbInit(void);
void UsbFree(void); void UsbFree(void);
void UsbTransmitPacket(blt_int8u *data, blt_int8u len); void UsbTransmitPacket(blt_int8u *data, blt_int8u len);
blt_bool UsbReceivePacket(blt_int8u *data); blt_bool UsbReceivePacket(blt_int8u *data, blt_int8u *len);
/**************************************************************************************** /****************************************************************************************
* Hook functions * Hook functions

View File

@ -104,7 +104,7 @@ static void XcpCmdProgramPrepare(blt_int8u *data);
* Hook functions * Hook functions
****************************************************************************************/ ****************************************************************************************/
#if (XCP_PACKET_RECEIVED_HOOK_EN == 1) #if (XCP_PACKET_RECEIVED_HOOK_EN == 1)
extern blt_bool XcpPacketReceivedHook(blt_int8u *data); extern blt_bool XcpPacketReceivedHook(blt_int8u *data, blt_int8u len);
#endif #endif
#if (XCP_RES_PAGING_EN == 1) #if (XCP_RES_PAGING_EN == 1)
@ -193,17 +193,22 @@ void XcpPacketTransmitted(void)
/************************************************************************************//** /************************************************************************************//**
** \brief Informs the core that a new packet was received by the transport layer. ** \brief Informs the core that a new packet was received by the transport layer.
** \param data Pointer to byte buffer with packet data. ** \param data Pointer to byte buffer with packet data.
** \param len Number of bytes in the packet.
** \return none ** \return none
** **
****************************************************************************************/ ****************************************************************************************/
void XcpPacketReceived(blt_int8u *data) void XcpPacketReceived(blt_int8u *data, blt_int8u len)
{ {
#if (XCP_PACKET_RECEIVED_HOOK_EN == 1)
#if (XCP_PACKET_RECEIVED_HOOK_EN == 0)
/* suppress compiler warning due to unused parameter. */
(void)len;
#else
/* give the hook function a chance to process this packet. A return value of BLT_TRUE /* give the hook function a chance to process this packet. A return value of BLT_TRUE
* indicates that the hook function processed the packet and that no further processing * indicates that the hook function processed the packet and that no further processing
* is required. * is required.
*/ */
if (XcpPacketReceivedHook(data) == BLT_TRUE) if (XcpPacketReceivedHook(data, len) == BLT_TRUE)
{ {
/* packet processed by hook function so no need to continue. */ /* packet processed by hook function so no need to continue. */
return; return;

View File

@ -235,7 +235,7 @@
void XcpInit(void); void XcpInit(void);
blt_bool XcpIsConnected(void); blt_bool XcpIsConnected(void);
void XcpPacketTransmitted(void); void XcpPacketTransmitted(void);
void XcpPacketReceived(blt_int8u *data); void XcpPacketReceived(blt_int8u *data, blt_int8u len);
/**************************************************************************************** /****************************************************************************************