Go Down

Topic: printf on DUE (Read 2091 times) previous topic - next topic

PoohDuino

Hello all,

I want printf support in my Due sketches and
have followed instructions as given at this link: http://playground.arduino.cc/Main/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.

stimmer

It looks like stdout is already redirected to the programming port UART on the due - try this:
Code: [Select]
#include <stdio.h>

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

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


Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

PoohDuino

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

Thanks.

stimmer

Code: [Select]
#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);
}
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

PoohDuino

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

Thanks again.

PoohDuino

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?

stimmer

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: http://sourceware.org/newlib/ Not all of it will be relevant to the Due.
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

sohini25

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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy