printf on DUE

Hello all,

I want printf support in my Due sketches and
have followed instructions as given at this link: Arduino Playground - Printf
but I get compile failures ...
'_FDEV_SETUP_WRITE' was not declared in this scope
'fdev_setup_stream' was not declared in this scope

I have included stdio.h in the sketch (where the above are defined) but to no avail. If I change the
target board to, say, the Uno then the compile passes. What am I missing?

Thanks.

It looks like stdout is already redirected to the programming port UART on the due - try this:

#include <stdio.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  printf("hello world!\n");
}

Thank you. You are right it works!
Any ideas on how I can add floating point printf() support?

Thanks.

#undef printf
#include <stdio.h>
void setup() {
  Serial.begin(9600);
}

float q=0.1;
void loop() {
  q+=0.1;
  printf("hello world! %f\n",q);
}

Yes working again. Thanks.
Where are you getting all this wonderful information from?

Thanks again.

I have another issue with printf(). I only get output if the string is terminated with "\n"
how do I get output regardless of whether the string is terminated with a NEWLINE?

Where is the DUE printf support documented?

fflush(stdout); - this is standard printf behaviour and is not a bug.

There is no proper documentation (yet) as the Due is too new, but there is some documentation here: The Newlib Homepage Not all of it will be relevant to the Due.

Hi,

I am unable to get an output with printf() using the code as suggested in earlier post for this message.

#include <stdio.h>

void setup() {
Serial.begin(9600);
}

void loop() {
printf("hello world!\n");
}

Can you tell me what particular file to include in my arduino sketch to get printf() support. I am using Arduino IDE 1.5.2 with Eclipse.

Anyways, why fdev_setup_stream is unaccessible on due?