Replicated select case index not in range of input array

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
aclassifier
Respected Member
Posts: 483
Joined: Wed Apr 25, 2012 8:52 pm
Contact:

Replicated select case index not in range of input array

Post by aclassifier »

The code below has always given me iof_client [0..2]

Code: Select all

conn_if_t all_conns [3]; // parameter in setup of Server1

void Server1 (
    server conn_if_t i_conns[3]); {

    while (1) {
        select {
            case i_conns[unsigned iof_client].do_temp (const unsigned val_in) -> unsigned val_return : {
                // iof_client is [0..2]
                ...
However, the below gives me iof_client [0..23]. In other words, one index per outer interface, like an ip address so to say.

Code: Select all

conn_if_t all_conns [8][3]; // parameter in setup of Servers8 are now all_conns[0], all_conns[1], all_conns[2], ie. I have 8 of Servers8

void Servers8 (
    server conn_if_t i_conns[3]); {
   
   unsigned my_array [3];
   
    while (1) {
        select {
            case i_conns[unsigned iof_client].do_temp (const unsigned val_in) -> unsigned val_return : {
                // iof_client is [0..23], in groups of [0..2], [3..5], ... [21,22,23] for the 8 Servers8
                const unsigned usable_index = (iof_client % 3); // [0..2] to avoid 'out of range' crash
                my_array[usable_index] = val_in;
                ...
                
Is this right? I assume it is.. But why?

But I couldn't find any reference to it in any of the documentation..?


--
Øyvind Teig
Trondheim (Norway)
https://www.teigfam.net/oyvind/home/
Post Reply