Go Down

Topic: printf() function for Arduino Due (Read 1 time) previous topic - next topic


I am using Arduino Due IDE 1.5.2 with Eclipse Juno and Arduino Eclipse Plugin V2. I am trying to implement the Relic Toolkit library on Due. But it requires printf() support. Whenever I am trying to implement the below code

int serial_putchar(char c, FILE* f) {
    if (c == '\n') serial_putchar('\r', f);
    return Serial.write(c) == 1? 0 : 1;

FILE serial_stdout;

void setup(){

    // Set up stdout
    fdev_setup_stream(&serial_stdout, serial_putchar, NULL, _FDEV_SETUP_WRITE);[/b]
    stdout = &serial_stdout;

    printf("My favorite number is %6d!", 12);

I get the error message as
_FDEV_SETUP_WRITE' was not declared in this scope
Symbol '_FDEV_SETUP_WRITE' could not be resolved.

Can anybody help to resolve this issue.

Your help will be highly appreciated.


Do you want to be able to define different serial devices as stdout?  Or hard code to say the main USB port?

You could define printf as just sending the char to the usb - open usb at the baud rate in Begin - Serial.begin(baudrate) then printf would send the char as a Serial.print(c); (the file handle would be ignored if you share a code base).


Actually i need printf() support for implementing Relic Toolkit library. Even on including stdio.h header file, why is printf() not working. Can you please explain your approach of having a way out.

Go Up