Forum: Compiler & IDEs Wie funktioniert printf ais WinAVR?


von Chris Blues (Gast)


Lesenswert?

Mein letzte Chance nach dtosstrf ist ja nun printf ;-)

Kompilieren tut sich das Ganze und ausprobiert hab ich alle möglichen 
printf-Befehle... nur ausgegeben wird nix?

Speicherprobleme hin oder her: aber wie funktioniert der printf-Befehl 
der WinAVR-Edition eigentlich?

Lieben Gruss,
Chris

von Joerg Wunsch (Gast)


Lesenswert?

Eigentlich enthält die Doku ein kleines Beispiel.  Hast Du die
denn gelesen? ;-)  Siehe unter "Standard IO facilities", dort die
Funktion uart_putchar() (oder so ähnlich).  Du mußt ein
fdevopen() damit machen.

Ein umfangreicheres Beispiel für die Doku ist noch in Arbeit...

von Chris Blues (Gast)


Lesenswert?

Natürich hab ich erst die Doku durchgelesen... ich mach immer DAS 
zuerst, was schneller geht, und hier im Forum auf Antwort warten ist 
definitiv nicht das schnellste ;-)

Dann darf ich wohl auf das umfangreichere Beispiel warten... mit der 
Doku ist bisher nicht viel anzufangen (ich muss ein fdevopen... da wär 
ich nie drauf gekommen, bin ja kein Hellseher...)...

Bis dann,
Chris

von Joerg Wunsch (Gast)


Lesenswert?

Ähem, das steht nun aber wirklich drin:

``The standard streams stdin, stdout, and stderr  are provided, but 
contrary to the C standard, since avr-libc has no knowledge about 
applicable devices, these streams are not already pre-initialized at 
application startup. Also, since there's no notion of "file" whatsoever 
to avr-libc, there's no function fopen() that could be used to associate 
a stream to some device. (See note 1.) Instead, function fdevopen()  is 
provided to associate a stream to a device, where the device needs to 
provide a function to send a character, to receive a character, or both. 
There's no differentiation between "text" and "binary" streams inside 
avr-libc. Character \n is sent literally down to the device's put() 
function. If the device requires a carriage return (\r) character to be 
sent before the linefeed, its put() routine must implement this (see 
note 2).''

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.