How to redirect printing functions via xSCOPE
version
1.1.1
scope
Example.
This code is provided as example code for a user to base their code on.
description
How to redirect printing functions via xSCOPE
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.
xSCOPE is fully supported on hardware platforms which provide an XMOS link between the target device and the XSYS development connector, it is also supported using xSIM.
View the document (xSCOPE overview) for further information on tracing data from XMOS applications.
This example provides a demonstration of redirecting the standard printing routines available in the xTIMEcomposer tools via the xSCOPE trace system. Redirecting printing over xSCOPE provides a streaming print capability that does not stop the xCORE device when a print message is issued. The allows printing to be done from applications which have real time constraints providing a valuable debugging tool for the developer.
In this case the standard printf() call is redirected via xSCOPE.
The redirection is handled by the user providing a config.xscope file which is picked up as part of the application build. In this example timed print redirection is specfied which sends print messages via xSCOPE and displays a timestamp for each print message sent along with the message data.
This example assumes you are familiar with creating a run configuration and enabling the associated xSCOPE options in that run configuration in xTIMEcomposer Studio or using the command line tools.
int main (void) { par { on tile[0]: { for (int i = 0; i < 10; i++) { printf("value of i is %d\n", i); } } } return 0; }