edgeimpulse / example-standalone-inferencing-zephyr

17 stars 7 forks source link

Printing floats in Zephyr #7

Closed MarkoSagadin closed 4 years ago

MarkoSagadin commented 4 years ago

There is a bug (or maybe feature) in Zephyr with printf implementation: buffer will be sent over serial only after calling printf with newline character or when buffer fills up.

VojislavM commented 4 years ago

printf and printk have differences in the implementation and separate buffers. So printk can push stuff without a new line, but printf cannot do that.

MarkoSagadin commented 4 years ago

Current solution is to replace all printk calls with printf's, then it works, this can be seen in commit 8bac408.

We can consider this as a workaround, as people coming from Zephyr are used to printk, not printf. If this presists we have to write it to README.

VojislavM commented 4 years ago

bu adding this line to setup:

setvbuf(stdout, NULL, _IONBF, 0);

the printf output won't be buffered and will be printed immediately without a new line. @MarkoSagadin

MarkoSagadin commented 4 years ago

I implemented this in commit a95aab4, this solved the problem like you wrote.