How to use memcpy with interface array arguments
version
1.1.1
scope
Example.
This code is provided as example code for a user to base their code on.
description
How to use memcpy with interface array arguments
boards
Unless otherwise specified, this example runs on the SliceKIT Core Board, but can easily be run on any XMOS device by using a different XN file.
Interface functions can take array arguments like normal functions:
interface my_interface { void fill_buffer(int buf[n], unsigned n); };
At the server end of the interface, the memcpy in string.h can be used to copy local data to the remote array. This will be converted into an efficient inter-task copy.
void task2(server interface my_interface c) { int data[5] = {1,2,3,4,5}; select { case c.fill_buffer(int a[n], unsigned n): // Copy data from the local array to the remote memcpy(a, data, n*sizeof(int)); break; } }