Hi,
I developed a very simple program in order to read data from a serial gps.
I've used the module_uart_rx and module_uart_tx available at https://github.com/xcore.
Now I'm trying to wrap all the code that I wrote in library.
Based on the example available at https://github.com/xcore/sc_uart/blob/m ... rc/main.xc
the modules uart_rx/tx create two specific threads: one for reading data and one for writing data.
My idea would be to provide a sort of gps_run() function that, after setting all the parameters, starts the read and write thread automatically.
The problem seems that the par {} construct can be used only in the main function. This would mean that, in my case, I should explicitly declare 3 threads, one for reading from serial, one for writing and one that should consume the data from gps.
Is there a way to create more threads from a generic function that is not the main function?
Thanks
Use of par{} on a function that is not the main
-
- Member++
- Posts: 19
- Joined: Tue Jun 16, 2015 10:50 pm
-
- Active Member
- Posts: 62
- Joined: Mon Jun 10, 2013 2:14 pm
par works outside of main:
Code: Select all
// xcc -report -target=XS1-L8A-64-TQ48-C5 par-outside-main.xc -o par-outside-main.xe
void
read()
{
while (1)
{
select {}
}
}
void
write()
{
while (1)
{
select {}
}
}
void
gps_run()
{
par
{
read();
write();
}
}
int
main()
{
gps_run();
return 0;
}
-
- Member++
- Posts: 19
- Joined: Tue Jun 16, 2015 10:50 pm
Hi,
thank for your help.
Following your example I was able to fix the problem.
My error was in another function that confused me, thinking that the problem was on the par construct{}.
The error was: multi-tile main must consist of single non-empty par statement
Thanks again!
thank for your help.
Following your example I was able to fix the problem.
My error was in another function that confused me, thinking that the problem was on the par construct{}.
The error was: multi-tile main must consist of single non-empty par statement
Thanks again!