Passing partial interface arrays to tasks

Technical questions regarding the XTC tools and programming with XMOS.
hasde
Member
Posts: 9
Joined: Thu Aug 11, 2016 3:52 pm

Passing partial interface arrays to tasks

Post by hasde »

Hello,
I tried splitting the client side of an interface array between two tasks (using xTIMEcomposer 14.2.1), the server task receives the entire array.

Example:

test_if interfaces[2];

par
{
server_task(interfaces, 2);

client_task(&interfaces[0], 1);
client_task(&interfaces[1], 1);
}

However, when passing something like &interfaces[1] to the client tasks (supplying the correct number of remaining interfaces also, in this case 1), the compilation fails with an internal compiler error. Is this intended, ie. what I want to do is not supported?

Best regards
Sebastian


User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

I think you just want to pass the interface to the client tasks rather than a pointer to interface
hasde
Member
Posts: 9
Joined: Thu Aug 11, 2016 3:52 pm

Post by hasde »

Hello larry,
that's what I am currently doing. However, the interface array will grow in the future, and handling several interfaces grouped in an array will simplify the code and extensibility a lot...

So any help or hints would be well appreciated :)

Best regards
Sebastian
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

Oh, I see

I don't think there's an easy way to do that. The best I can think of is passing the whole client side to a C function, which then passes it sliced to an XC function as a pair of arguments. Then par inside the XC function.

XC main:

Code: Select all

  void wrapper(client interface i i[], int n);
  par {
    server_task(i, 4);
    wrapper(i, 4);
  }
C file:

Code: Select all

  void combined(unsigned i1[], int n1, unsigned i2[], int n2);
  void wrapper(unsigned i[], int n)
  {
    combined(&i[0], 2, &i[2], 2);
  }
XC file:

Code: Select all

  void combined(client interface i i1[], int n1, client interface i i2[], int n2)
  {
    par {
      client_task(i1, n1);
      client_task(i2, n2);
    }
  }