Embedded TCP/IP stack: fnet_serial_vprintf

FNET

fnet_size_t fnet_serial_vprintf ( fnet_serial_stream_t  stream,
const fnet_char_t format,
va_list  arg 
)

Prints formatted variable argument list to the stream.

Parameters
streamStream descriptor.
formatFormat string.
argVariable arguments list. It shall have been initialized by va_start() macro
Returns
This function returns the number of characters that were successfully written, excluding the trailing null.
See also
fnet_serial_printf()

This function outputs formatted text to the stream, expanding the format placeholders with the value of the argument list arg.
This function behaves exactly as printf except that the variable argument list is passed as a va_list instead of a succession of arguments, which becomes specially useful when the argument list to be passed comes itself from a variable argument list in the calling function.

The syntax for a format placeholder is "%[Flags][Width][Length]Type".

  • Flags can be omitted or be any of:
    • - : Left justify.
    • + : Right justify.
    • 0 : Pad with leading zeros.
    • space : Print space if no sign.
  • Width is minimum field width. It can be omitted.
  • Length is conversion character. It can be omitted or by any of:
    • h : Short integer.
    • l : Long integer.
  • Type can by any of:
    • d, i : Integer.
    • u : Unsigned.
    • x, X : Hexadecimal.
    • o : Octal.
    • b : Binary.
    • p : Pointer.
    • c : Single char.
    • s : Char string.
    • n : Nothing.
Note
To save some bytes from all the hard coded strings the fnet_(s)printf() functions will expand all line feeds ("\n") inside the format string to CR LF ("\r\n"). So do not use "\r\n" in the format string - it will be expanded to "\r\r\n". It is save to add it via a parameter though, e.g. fnet_printf("%s", "\r\n");
This feature can be disable/enabled by the FNET_CFG_SERIAL_PRINTF_N_TO_RN configuration parameter.

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net