AnsweredAssumed Answered

RTCSERR_PCB_ALLOC error raised

Question asked by Hugo Bouchard on Aug 1, 2016
Latest reply on Aug 2, 2016 by Daniel Chen

Hello,

 

I'm trying to setup an UDP connection to broadcast data on the network but data are not sent and I get a RTCSERR_PCB_ALLOC error. I'm using MQX 4.1.1 on a MPC5668G.

 

Here is my initialisation of the comm stack:

 

    IPCFG_IP_ADDRESS_DATA stIPConfig;

    uint32_t u32Error;

    _enet_address au8Address;

 

    _RTCSPCB_init = 10;              /* maximum RTCSPCBs available */

    _RTCSPCB_grow = 2;              /* maximum RTCSPCBs available */

    _RTCSPCB_max = 20;               /* maximum RTCSPCBs available */

 

    /* Initialize Ethernet */

    u32Error = RTCS_create();

    if(RTCS_OK != u32Error)

    {

        _task_block();

    }

 

    ENET_get_mac_address((uint32_t)0, ENET_IPADDR, au8Address);

 

    /* Initialize ENET device */

    u32Error = ipcfg_init_device ((uint32_t)0, au8Address);

    if(RTCS_OK != u32Error)

    {

        _task_block();

    }

 

    stIPConfig.ip      = ENET_IPADDR;          //#define ENET_IPADDR   IPADDR(169,254,1,4)

    stIPConfig.mask    = ENET_IPMASK;     //#define ENET_IPMASK    IPADDR(255,255,0,0)

    stIPConfig.gateway = 0;

 

    u32Error = ipcfg_bind_staticip ((uint32_t)0, &stIPConfig);

    if(RTCS_OK != u32Error)

    {

        _task_block();

    }

 

And here is the code of my task that send the data:

 

void EthTask100msCycle(uint32_t u32Parameter)

{

    TIME_STRUCT stTimePtr;

    uint32_t u32TstCntr = 0U;

    uint32_t u32Socket;

    uint32_t u32Error;

    sockaddr_in stAddress;

    uint8_t au8TstBuffer[8];

 

    /* Initialize periodic timers to make task cyclic */

    _time_get_elapsed(&stTimePtr);

    stTimePtr.MILLISECONDS += TASK_KU32_ETH_100MS_START_OFFSET;

    (void)_timer_start_periodic_at(TimerCallbackFct, _task_get_td(MQX_NULL_TASK_ID), TIMER_ELAPSED_TIME_MODE, &stTimePtr, TASK_KU32_100MS_CYCLE);

 

    u32Socket = socket(AF_INET, SOCK_DGRAM, 0);

    if(RTCS_SOCKET_ERROR == u32Socket)

    {

        _task_block();

    }

 

    stAddress.sin_family      = AF_INET;

    stAddress.sin_port        = 11001;

    stAddress.sin_addr.s_addr = INADDR_BROADCAST;

 

    u32Error = bind(u32Socket, (const sockaddr *)&stAddress, sizeof(stAddress));

    if (RTCS_OK != u32Error)

    {

        _task_block();

    }

 

    while(1)

    {

        _task_block();

        u32TstCntr++;

 

        au8TstBuffer[0] = 'T';

        au8TstBuffer[1] = e';

        au8TstBuffer[2] = 's';

        au8TstBuffer[3] = 't';

        au8TstBuffer[4] = GET_DWORD_HIGH_BYTE(u32TstCntr);

        au8TstBuffer[5] = GET_DWORD_MID_HIGH_BYTE(u32TstCntr);

        au8TstBuffer[6] = GET_DWORD_MID_LOW_BYTE(u32TstCntr);

        au8TstBuffer[7] = GET_DWORD_LOW_BYTE(u32TstCntr);

 

        u32Error = sendto(u32Socket, au8TstBuffer, 8, RTCS_MSG_NOLOOP, (sockaddr *)&stAddress, sizeof(stAddress));

        u32Error = RTCS_geterror(u32Socket);          //Here error is 0x1310

    }

}

 

When I step through the code, I can see that function _partition_alloc_internal (at line 136) returns PARTITION_OUT_OF_BLOCKS. At one point, the last condition condition fails :

 

Line 136:

if ((partpool_ptr->PARTITION_TYPE == PARTITION_DYNAMIC) && partpool_ptr->GROW_BLOCKS

                && ((partpool_ptr->MAXIMUM_BLOCKS == 0) || (partpool_ptr->TOTAL_BLOCKS

                                < partpool_ptr->MAXIMUM_BLOCKS)))

{ (...) }

 

1. What am I doing?

 

2. Can someone explain to me what is a PCB (Packet Control Block) and they get freed?

 

Thanks for your help

Hugo

Outcomes