-
-
Notifications
You must be signed in to change notification settings - Fork 7k
LAST printf always missing ? #2908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Uhm, by default printf doesn't actually work on Arduino AFAIK? Your sketch also doesn't have a loop function. Could you provide a minimal, but complete example showing the problem? To take a guess at the cause: perhaps you are disabling interrupts and never re-enable them? That would cause the printed bytes to stay queued and never be actually sent. |
Thanks for replay.I have been using "officially published by Arduino " print class on thousandths of printf functions. The snippet provided is just one of the ways I have tested this.The for loop was just another way and it ALWAYS missed LAST iteration on LAST for loop. There are no interrupts involved and as I said - it will ALWAYS fail the last printf. I just did bare bones like this and it fails the second printf.
|
Ah, I missed you were on a Due, I don't know too much about the core implementation there :-) No clue what's going on there, though. Does the issue happen if you use Serial.print instead of printf? Does it happen if you add \n at the end of the last print? I'm wondering if there is some sort of line buffering somewhere in the stdio/printf stack. |
This is really interesting. Apparently buried in all the ASF & CMSIS stuff is more hardware serial code. It appears to be doing line buffering, holding prior text until you print a newline. For example, if you try running this, you'll get the last line.
|
Hey Paul, I just took a break painting piano room ( honeydo) and guess what, came up with same idea.Build EXACT same code as you did (looks familiar !) and pasted it over Arduino BareMinimum sketch and it works!YES, I am still working on the USB video and have ASF code all over the place ( based on USBHost etc.) and this shows up after I get USB into CONFIGURING state. Maybe sooner, but that is where I first noticed this. I am using interrupts after all the USB configuring is finished, but this shows up before that. I am not thru analyzing the interrupt, sorry , that is still "TO DO". |
Here is printf and Serial test
And here is the output - should be 2 of each Serial & printf .
|
Here is a result of "programming while you sleep" . It obviously "works" only in BareMinimum sketch without parameters.
|
This seems like normal behavior to me for buffered standard i/o - that same thing can happen in real operating systems. |
Here is a partial copy of one my previous posts when I used fflush() with same failure. So the solution is to add fflush to the Arduino print class modification. There are no interrupts involved and as I said - it will ALWAYS fail the last printf. I just did bare bones like this and it fails the second printf.
|
Have been running 1.6.0 Nov build on Due and just noticed this.
I am reluctant to "upgrade" to 1.6.3 "just because" since 1.6.0 works for me so far.
I can hack this problem by duplicating the last printf lines but would like to know what COULD be the real cause of this.
Here is a simple test of printf and its output
The problem is - LAST printf is always missing from monitor output.
Sample code
The text was updated successfully, but these errors were encountered: