overflow error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

overflow error

748 Views
13560436802
Contributor II

Hi, I have a problem about overflow error!

There are two device(A and B) communication each other, process steps as below:

1. A send a packet to B;

2. B read the data and reply a packet to A;

3. B occurred a overflow error when reply a packet;

pastedImage_2.png

pastedImage_1.png

----------------------------------------------------------------------------------

This is the send or reply packet data code:

PUBLIC void vAppWriteAttribute(uint16 u16DestAddr, uint8 *wData, uint8 length)
{
uint8_t hexLength = 0;
uint8 u8FramControl = 0;
uint16 u16offset;
uint8 *pu8TransactionSequenceNumber = 0;
uint8 u8CommandId = 0x02;
uint16 u16AttribId;
uint16 u16Size;
uint8 i = 0;
uint8 tab[PACKAGE_LEN_MAX];

*pu8TransactionSequenceNumber = u8GetTransactionSequenceNumber();
DBG_vPrintf(TRUE, "vAppWriteAttribute: \n" );


PDUM_teStatus status;

PDUM_thAPduInstance Apdudata = PDUM_hAPduAllocateAPduInstance( apduZDP );
if( Apdudata == PDUM_INVALID_HANDLE )
{
/* problem allocating APDU instance memory*/
DBG_vPrintf(DEBUF_COMMAND_SERIL, "APP: Unable to allocate APDU memory\n");
}
else
{
if ( PDUM_E_OK != PDUM_eAPduInstanceSetPayloadSize(Apdudata, ( hexLength) ) )
{
DBG_vPrintf(DEBUF_COMMAND_SERIL, "vAppWriteAttribute: PDUM_eAPduInstanceSetPayloadSize error!!\n");
PDUM_eAPduFreeAPduInstance( Apdudata );
return;
}

u8FramControl = ( 0x00 ) |
( ( ( 0 ) ? 1 : 0 ) << 2 )|
( ( ( 0 ) ? 1 : 0 ) << 3) |
( 1 << 4 );
u16offset = PDUM_u16APduInstanceWriteNBO ( Apdudata,
0,
"bbb",
u8FramControl,
*pu8TransactionSequenceNumber,
u8CommandId );


u16Size = length;
i = 0;
memcpy(tab, wData,u16Size);
u16AttribId = FUNC_ATTRIBUTE_ID;
u16offset += PDUM_u16APduInstanceWriteNBO ( Apdudata,
u16offset,
"h",
u16AttribId ); // attribute id

u16offset += PDUM_u16APduInstanceWriteNBO ( Apdudata,
u16offset,
"b",
E_ZCL_ARRAY ); //attribute type

for(i=0; i<u16Size; i++){
   u16offset += PDUM_u16APduInstanceWriteNBO ( Apdudata, u16offset, "b", tab[i] );
}
uint16 byteCount = u16Size + 6;
if( byteCount == 0 )
{
   /* no data was written to the APDU instance*/
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "APP: No data written to APDU\n");
   PDUM_eAPduFreeAPduInstance( Apdudata );
}
else
{
   PDUM_teStatus pdumStatus = PDUM_eAPduInstanceSetPayloadSize( Apdudata, byteCount );

   if( pdumStatus != PDUM_E_OK )
   {
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "SendData: SetPayloadSize error, Status = %d\n", pdumStatus);
   PDUM_eAPduFreeAPduInstance( Apdudata );
   }
else
{
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "vAppWriteAttribute: written to APDU: %d\n",    PDUM_u16APduInstanceGetPayloadSize(Apdudata));
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "vAppWriteAttribute: get APDU size: %d\n",    PDUM_u16APduGetSize(apduZDP));
/* request data send to destination*/
   status = ZPS_eAplAfUnicastAckDataReq(
   Apdudata, // APDU instance handle
   0x0008, // cluster ID
   1, // source endpoint
   1, // destination endpoint
   u16DestAddr, // destination network address
   ZPS_E_APL_AF_UNSECURE, // security mode
   0, // radius
   NULL // sequence number pointer
   );
if( status != ZPS_E_SUCCESS )
{
   // problem with request
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "vAppWriteAttribute: not successful. Return: 0x%x\n", status);
   PDUM_eAPduFreeAPduInstance( Apdudata );
}
else
{
   /* TX data request successful*/
   /*Once the request has been successfully sent, the APDU instance is automatically deallocated by the stack*/
   DBG_vPrintf(DEBUF_COMMAND_SERIL, "vAppWriteAttribute: successful. Return: 0x%x\n", status);
}
}
}
}
}

------------------------------------------

This is the read packet data code:

PUBLIC void readAttbuteData(tsZCL_CallBackEvent *psEvent, uint8 *packData, uint8_t *Len)
{
uint8 au8LinkTxBuffer[256];
uint16 u16Length = 0;
uint8* dataPtr;
uint8 u8Size;
uint8 i = 0;
dataPtr = ( uint8* ) PDUM_pvAPduInstanceGetPayload ( psEvent->pZPSevent->uEvent.sApsDataIndEvent.hAPduInst );
u8Size = PDUM_u16APduInstanceGetPayloadSize ( psEvent->pZPSevent->uEvent.sApsDataIndEvent.hAPduInst );
while (i < u8Size)
{
   ZNC_BUF_U8_UPD( &au8LinkTxBuffer [u16Length], dataPtr[ i ], u16Length );
   i++;
}
DBG_vPrintf(TRUE, "endpoint get application data length[%d]:------------------------\n",u16Length-6);
for(i=0; i<u16Length-6; i++){
   DBG_vPrintf(TRUE, "0x%x ",au8LinkTxBuffer[i+6]);
}
   DBG_vPrintf(TRUE, "--------------------\n");


memcpy(packData,&au8LinkTxBuffer[6],u16Length-6);
*Len = u16Length-6;

//Once the response has been dealt with, the application must de-allocate the APDU instance using the function PDUM_eAPduFreeAPduInstance()
if (psEvent->pZPSevent->uEvent.sApsDataIndEvent.hAPduInst != NULL )
{
   DBG_vPrintf(TRUE, "readAttbuteData: free apdu\n");
   PDUM_eAPduFreeAPduInstance(psEvent->pZPSevent->uEvent.sApsDataIndEvent.hAPduInst);
}
}

0 Kudos
Reply
1 Reply

638 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Dylan,

How long is the data that you are sending?

Do you have a lot of PDUM_u16APduInstanceWriteNBO? Is it works when you sent this by the A device?

What is the AN that you take as reference?

Regards,

Mario

0 Kudos
Reply