Pass arbitrarily sized data between components

Hiya,

What’s the ‘Legato Way’ of passing an arbitrarily sized array from once component to another?

in ‘C’ I would something like this:

void doIt(uint8_t *data, size_t len)
{
    // ... process data
    return;
}

void buildIt()
{
    uint8_t *D = NULL;
    size_t len = 100;

    D = (uint8_t *)calloc(len, sizeof(uint8_t));

    // .... do something to build array

    doIt(D, len);
    free(D);

    return;
}

I can create an API for a component that has a fixed maximum length of IN data, but how do I pass an array of an unknown maximum length (at build time) from one component to another?

ciao, Dave

I would use one of the following methods:

  1. You can create a pipe and pass one end of the pipe over the API, then write your data to the pipe.
  2. You can break up the data into chunks and pass a chunk at a time to the API.

Hiya,

Thanks for the ideas. I’ve just finished implementing the ‘pipe’ between two components and it seems to be working fine.

ciao, Dave