sending arrays over channels

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
gerrykurz
XCore Addict
Posts: 204
Joined: Sun Jun 01, 2014 10:25 pm

sending arrays over channels

Post by gerrykurz »

What is the syntax for sending an array over a channel?
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Sending arrays over channels was not possible last time I tested (a few tools version ago), I don't think this has changed.

You either have to transmit it element by element or wrap it in a struct.
TMentink
Junior Member
Posts: 7
Joined: Sat Apr 19, 2014 7:52 pm

Post by TMentink »

You can try the new interfaces system to send an array.

Code: Select all

interface GPS_Interface{
    [[notification]] slave void GPS_NewData();
    [[clears_notification]] void GPS_GetLatitude(unsigned char SendLatitude[]);
    [[clears_notification]] void GPS_GetLongitude(unsigned char SendLongitude[]);
    [[clears_notification]] void GPS_GetSpeed(unsigned char SendSpeed[]);
}GPS_Interface ;

Code: Select all

            case GPS_Data.GPS_GetLongitude(unsigned char SendLongitude[]):
                for (int i = 0; i < 11; i++)
                {
                    SendLongitude[i] = Longitude[i];
                }
                break;

Code: Select all

                unsigned char Longitude[11] = {0};

                GPS_Data.GPS_GetLatitude(Latitude);
In this way you can transmit a array over a interface. Set the array sender as server, and the receiver as client.