Hi,
I'm using notifications on an array of interfaces and found something odd testing the server side.
In the select case section where get_data() get's handled if I do not include a new line in the printf the values get displayed in the console in batches and some time after the clients have sent there debug data to the console.
It's a bit hard to explain so see attached project.
Using xTIMEcomposer v14.4.1 (build 235-acbb966, Dec-01-2019)
Kind regards
Strange printf behavior
- notDilbert
- Member
- Posts: 14
- Joined: Mon Feb 25, 2019 3:05 pm
Strange printf behavior
- Attachments
-
- strange_printf_behavior.zip
- (10.46 KiB) Downloaded 147 times
- strange_printf_behavior.zip
- (10.46 KiB) Downloaded 147 times
Hi. Have not reviewed your code but:
a) standard printf is blocking and not recommended for use
b) instead, consider the use of real-time printf. See the attached document.
a) standard printf is blocking and not recommended for use
b) instead, consider the use of real-time printf. See the attached document.
- notDilbert
- Member
- Posts: 14
- Joined: Mon Feb 25, 2019 3:05 pm
Hi,
Thanks for the reply.
I am using real-time/xScope/xTag printf. But with the adding -fxscope arg to XCC_FLAGS in makefile and creating config.xscope file method.
Come on have a look, you will be surprised.... I think.
Uncommenting the the line printf("\n"); in app_server.xc
Changes the console output from
to
Notice the two notifications fire two seconds apart.
So I doubt it is a timing/blocking issue.
Thanks for the reply.
I am using real-time/xScope/xTag printf. But with the adding -fxscope arg to XCC_FLAGS in makefile and creating config.xscope file method.
Come on have a look, you will be surprised.... I think.
Uncommenting the the line printf("\n"); in app_server.xc
Code: Select all
void server_task(server interface notify_if c[n], unsigned n)
{
timer t;
uint32_t time;
const uint32_t period = 200000000; // 1=100us
t :> time;
int data = 0;
printf("server_task() started\n");
while(1)
{
select
{
case c[int i].get_data(int id) -> int return_value:
printf("id=%d i=%d", id, i); // unexpected console output without new line
//printf("\n"); // adding this produces expected console output
return_value = data;
break;
case t when timerafter(time) :> void:
if (++data == 0) break;
//printf("server_task: sending notifications\n");
for (int i=0; i<n; i++) c[i].data_ready();
time += period;
break;
}
}
}
Changes the console output from
Code: Select all
server_task() started
client_a_task() started
client_b_task() started
1
1
2
2
3
3
4
4
id=1 i=0id=2 i=1id=1 i=0id=2 i=1id=1 i=0id=2 i=1id=1 i=0id=2 i=15
5
6
6
to
Code: Select all
server_task() started
client_a_task() started
client_b_task() started
id=1 i=0
1
id=2 i=1
1
id=1 i=0
2
id=2 i=1
2
id=1 i=0
3
id=2 i=1
3
id=1 i=0
4
id=2 i=1
4
id=1 i=0
5
id=2 i=1
5
id=1 i=0
6
id=2 i=1
6
Notice the two notifications fire two seconds apart.
So I doubt it is a timing/blocking issue.