Hi
I was following this AN10127 in http://www.xmos.com/support/examples, but after I compile (with no errors or warnings) and try the xrun command given in the example xrun just crashes. I have a STARTKIT connected to the computer which I have checked works using xrun -l and other projects.
The xsim command given works fine however. Could someone help me out here?
Also, I plan to apply this to xC (the example is in C). Is there a way to do this? It seems you can't have input arguments in the main function of .xc files.
Thanks
Pass arguments to the target application (xC) Topic is solved
-
- Active Member
- Posts: 33
- Joined: Sat Mar 12, 2016 3:12 pm
Sorry about this. I have just tested this my end and can confirm that this is broken. I will investigate why and see whether there is a work-around I can give you.
Thanks for reporting this. Unfortunately it doesn't look like there is a work-around for this.
I have fixed this, so it should be working in the next tools release.
I have fixed this, so it should be working in the next tools release.
-
- Active Member
- Posts: 33
- Joined: Sat Mar 12, 2016 3:12 pm
So would I be able to work this in .xc? Do you have any idea when the tool will be released?
Thanks
Thanks
The bug is in the xrun on the host, so doing it in .xc will not work any better.
-
- Active Member
- Posts: 33
- Joined: Sat Mar 12, 2016 3:12 pm
Is it possible to modify the code to get this working in .xc? Sorry I am relatively new to xc
You can rename the c file as a .xc file and change the main to:
This will run on the simulator, but will still crash in xrun.
If you have a multi-tile main then the argument parsing in XC is not the same as you can't pass arguments to a multi-tile main. Instead you'd need to have two files, the main.xc:
And a parse.c:
Again, this will compile and run on the simulator, but not on the hardware.
Code: Select all
#include <stdio.h>
int main(unsigned int argc, char *unsafe argv[argc]) {
printf("argc = %d\n", argc);
for (unsigned int i = 0; i < argc; ++i) {
printf("argv[%d] = %s\n", i, argv[i]);
}
return 0;
}
If you have a multi-tile main then the argument parsing in XC is not the same as you can't pass arguments to a multi-tile main. Instead you'd need to have two files, the main.xc:
Code: Select all
#include <xs1.h>
#include <platform.h>
void parse_command_line(int id);
int main () {
par {
on tile[0] : parse_command_line(1);
on tile[1] : parse_command_line(2);
}
return 0;
}
Code: Select all
#include <stdio.h>
#include <syscall.h>
void parse_command_line(int id) {
char buf[256];
int argc = _get_cmdline(buf, 256);
char **argv = (char **)&buf;
for (int i = 0; i < argc; i++) {
printf("%d: %s\n", id, argv[i]);
}
}