Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

Formatted output functions.

Formatted character output. More...

Functions

int NutPrintBinary (NUTDEVICE *dev, const char *data, int len)
 Write a buffer to a specified device. More...

int NutPrintBinary_P (NUTDEVICE *dev, PGM_P data, int len)
 Write a buffer in program space to a specified device. More...

int NutPrintString (NUTDEVICE *dev, const char *str)
 Print a string on a specified device. More...

int NutPrintString_P (NUTDEVICE *dev, PGM_P str)
 Print a string in program space on a specified device. More...

int NutPrintInteger (NUTDEVICE *dev, u_long val, u_char radix, u_char width, u_char flags)
 Print a numeric value on a specified device. More...

int NutPrintFormat (NUTDEVICE *dev, const char *fmt,...)
 Print parameters using a format string. More...

int NutPrintFlush (NUTDEVICE *dev)

Detailed Description

Formatted character output.

This module contains routines to print strings and numeric values.

All output function in this module will block until all bytes have been transfered to the output buffer. If this buffer gets filled up, transmission to the physical device is started automatically in the background.

Version:
2.1.1
Author:
Harald Kipp, egnite Software GmbH

Function Documentation

int NutPrintBinary ( NUTDEVICE * dev,
const char * data,
int len )
 

Write a buffer to a specified device.

Data may not be immediately transmitted to the physical, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.

If the buffer is in program space, use NutPrintBinary_P() instead.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
data   Buffer to be written.
len   Number of characters to be printed.

Returns:
The number of characters printed or -1 in case of an error.

int NutPrintBinary_P ( NUTDEVICE * dev,
PGM_P data,
int len )
 

Write a buffer in program space to a specified device.

Data may not be immediately transmitted to the physical, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.

To print a buffer in RAM, use NutPrintBinary().

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
data   Buffer in program space to be printed.
len   Number of characters to be printed.

Returns:
The number of characters printed or -1 in case of an error.

int NutPrintFlush ( NUTDEVICE * dev )
 

Send buffered characters to the specified device.

If the device's output buffer contains any, the transmitter is started, if not already running. The function returns immediately, without waiting for data being completely transmitted.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.

Returns:
0 on success, -1 otherwise.
Examples:
httpd/nutmain.c, portdio/portdio.c, tcps/tcps.c, threads/threads.c, timers/timers.c, and uart/nutmain.c.

int NutPrintFormat ( NUTDEVICE * dev,
const char * fmt,
... )
 

Print parameters using a format string.

This function formats and prints characters and values to a specified character output routine.

The format string consists of ordinary characters, escape sequences, and format specifications. Ordinary characters and escape sequences are copied to the output routine in the order of their appearance. The format is scanned from left to right. If a format specification is encountered, the value of the corresponding argument is converted and output according to that format specification. If there are more arguments than format specifications, the extra arguments are ignored. If there are more format specifications than arguments, the results are undefined.

Recognized format specifiers are:

  • %c prints a character.
  • %s prints a string.
  • %o prints a numerical value in octal digits.
  • %d prints a signed numerical value in deciaml digits.
  • %u prints an unsigned numerical value in decimal digits.
  • %x prints a numerical value in hexadecimal digits using lowercase letters.
  • %X prints a numerical value in hexadecimal digits using uppercase letters.
The resulting string may not be transmitted immediately, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.
Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
fmt   Format string.

Returns:
The number of characters printed, or a negative value in case of an output error.
Examples:
portdio/portdio.c, tcps/tcps.c, timers/timers.c, and uart/nutmain.c.

int NutPrintInteger ( NUTDEVICE * dev,
u_long val,
u_char radix,
u_char width,
u_char flags )
 

Print a numeric value on a specified device.

The numeric value will be converted to an ASCII string and printed to the specified stream device. The string may not be transmitted immediately, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
val   Value to be printed.
radix   Number base, may be any value between 2 and 16.
width   Minimum width or 0 if no justification required.
flags   Format flags. Any of the following may be ored:
  • FMTFLG_ZERO for output padding with zeros.
  • FMTFLG_PLUS forces printing a sign character.
  • FMTFLG_MINUS for left justification.
  • FMTFLG_SIGNED for signed values.
  • FMTFLG_CAPITAL for using capital letters with base above 10.
Returns:
The number of characters printed or -1 in case of an error.

See also:
Format flags
Examples:
portdio/portdio.c, and tcps/tcps.c.

int NutPrintString ( NUTDEVICE * dev,
const char * str )
 

Print a string on a specified device.

The string may not be immediately transmitted to the physical device, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.

If the string is defined in program space, use NutPrintString_P() instead.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
str   String to be printed.

Returns:
The number of characters printed or -1 in case of an error.
Examples:
httpd/nutmain.c, portdio/portdio.c, tcps/tcps.c, and threads/threads.c.

int NutPrintString_P ( NUTDEVICE * dev,
PGM_P str )
 

Print a string in program space on a specified device.

The string may not be immediately transmitted to the physical device, but stored in the output buffer. Call NutPrintFlush() to force immediate transmission.

If the string is defined in RAM, use NutPrintString() instead.

Parameters:
dev   Identifies the device that receives the data. This pointer must have been retrieved by using the NutDeviceOpen() function.
str   String in program space to be printed.

Returns:
The number of characters printed or -1 in case of an error.
Examples:
httpd/nutmain.c, and uart/nutmain.c.


© 2000-2001 by egnite Software GmbH - visit http://www.ethernut.de/