interface array problem

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
CousinItt
XCore Addict
Posts: 164
Joined: Wed May 31, 2017 6:55 pm

interface array problem

Postby CousinItt » Sat Nov 30, 2019 8:36 pm

Hi all,

this snippet of code is based on the ethernet example in AN00199. A library server, that takes an interface array, is running on one tile, with a client on the same tile, and there's another client running on another tile.

Code: Select all

int main()
{
  my_interface my_if[NUM_CLIENTS];

  par {
    on tile[1]: library_server(my_if, NUM_CLIENTS, ...);
    on tile[1]: local_client(my_if[0], ...);
    on tile[1]: etc...

    on tile[0]: another_client(my_if[1],...);
    on tile[0]: etc...
    }
    ...
}
This works fine if all the assignments are made in this way, but it gets messy when there are a lot of tiles and tasks. Suppose, for reasons of modularity, I'd like to split up the code and have a different module for each tile, e.g.

Code: Select all

par {
on tile[0]: tile_tasks_0(...);
on tile[1]: tile_tasks_1(...);
}
Where and how can the interface array be set up so that tile_tasks_1() will support both local and external clients? I've tried a few options and the compiler likes none of them.

Thanks.
fabriceo
Active Member
Posts: 33
Joined: Mon Jan 08, 2018 4:14 pm

Postby fabriceo » Sun Dec 01, 2019 5:44 pm

hi,
one way I understood in reviewing the main.xc of the usb audio app:

create a function containing par statement (with eventually many tasks), and having an interface (or an array of interface) as a parameter

then declare the interface in the main() body and call the function passing this interface as a parameter

in fact with xc compiler, the best to do (and sometime boring) is to pass everything as parameters. this way the compiler never claim about potential conflict to access a global resource and you can put some sensitive resources like channels and if in the main body

hope this helps
User avatar
CousinItt
XCore Addict
Posts: 164
Joined: Wed May 31, 2017 6:55 pm

Postby CousinItt » Sun Dec 01, 2019 8:39 pm

Hi Fabriceo,

thanks for your message. If I declare the interface array at the top level and pass it as an argument, the receivers of the argument have to declare that they are servers or clients. If, in tile_tasks_1 the array parameter is identified as "server" then I can't attach a local client to it. I can't declare a client argument for the same interface in the same function (to pass one member of the interface "back" up to the top level), and there doesn't seem to be any way to aggregate separate interfaces into an array, which could then be passed to the server. Hence I'm a bit stuck.

The only workaround I've found so far is to have a proxy process in tile_tasks_1 which will forward messages from the external client via a member of a local interface array in tile_tasks_1, but that seems clunky and unnecessary to me. I hope there's some way around this.

Who is online

Users browsing this forum: No registered users and 0 guests