- Main Page
- Modules
- Data Structures
- Files

# Console Input / Output
[User API: Nano Layer]

## Functions
NANOEXT void | c_nos_keyinput (UVAR_t key)
NANOEXT char | nosKeyGet (void)
NANOEXT UVAR_t | nosKeyPressed (void)
NANOEXT UVAR_t | p_putchar (char c)
NANOEXT void | c_nos_putcharReady (void)
NANOEXT void | nosPrintChar (char c)
NANOEXT void | nosPrint (const char *s)
NANOEXT void | nosPrintf1 (const char *fmt, arg a1)
NANOEXT void | nosSPrintf1 (char *buf, const char *fmt, arg a1)

## Detailed Description

Note: This API is part of the nano layer

The nano layer supplies a set of multitasking able console I/O functions. Note that the platform port must support some basic I/O mechanisms. For console output, pico]OS calls the function p_putchar to output a single character. This function may fail when a transmitter FIFO ran out of space, and the function c_nos_putcharReady should be called when the transmitter is ready again. Input from a terminal or keyboard is fet into pico]OS by calling the function c_nos_keyinput or by rising the software interrupt number zero with the keycode as parameter. Not all platform ports may support console I/O, please read the port documentation for further information.
Since the nano layer supplies also a set of printf and sprintf functions, you may no more need a large runtime library in some special cases.

## Function Documentation

NANOEXT void c_nos_keyinput | ( | UVAR_t | key | ) |

  | Keyboard input. This function is called by the architecture port to feed keyboard input into the nano layer. Parameters:
  | key | keycode of the pressed key
Note: NOSCFG_FEATURE_CONIN must be defined to 1 to have this function compiled in. The alternative to the use of this function is to use software interrupt 0 to feed keyboard data into the nano layer. See also: nosKeyGet, nosKeyPressed, NOSCFG_CONIO_KEYBUFSIZE

NANOEXT void c_nos_putcharReady | ( | void |  | ) |

| This is the optional handshake function for p_putchar. The handshake function is usefull for console output over a serial line. The function p_putchar will fail when the transmitter FIFO is full, and the nano layer will save the last character for later transmission. The platform port should than call c_nos_putcharReady when the transmitter FIFO has space again (when the last character has left the output shift register); most commonly this is signalled by a hardware interrupt, that would be used to call this handshake function. The purpose of this handshaking is to reduce CPU usage by avoiding polling on the standard output until the stdout is ready again. In the current implementation this function triggers a semaphore that wakes the task waiting for service on standard out. Note that this function must be supplied by the architecture port; it is not callable by the user. Note: To enable this handshake function, the define NOSCFG_CONOUT_HANDSHAKE must be set to 1.

NANOEXT char nosKeyGet | ( | void |  | ) |

| Wait and get the code of the next pressed key. This function blocks until the user presses a key on the keyboard and returns the code of the pressed key as result. Returns: ASCII-code of the pressed key Note: NOSCFG_FEATURE_CONIN must be defined to 1 to have this function compiled in. See also: nosKeyPressed, c_nos_keyinput, NOSCFG_CONIO_KEYBUFSIZE

NANOEXT UVAR_t nosKeyPressed | ( | void |  | ) |

| Test if a key was pressed. This function tests if a key code is available in the keyboard buffer. Even if no key is pressed yet, the function will immediately return. Returns: TRUE (nonzero) when a key code is available. Note: NOSCFG_FEATURE_CONIN must be defined to 1 to have this function compiled in. See also: nosKeyGet, c_nos_keyinput, NOSCFG_CONIO_KEYBUFSIZE

NANOEXT void nosPrint | ( | const char * | s | ) |

  | Print a character string to the console or terminal. This function prints a string of characters (text) to the console. A CR/LF conversion is performed, CR is preceding each LF. Parameters:
  | s | pointer to zero terminated ASCII string
Note: NOSCFG_FEATURE_CONOUT must be defined to 1 to have this function compiled in. See also: nosPrintChar, p_putchar

NANOEXT void nosPrintChar | ( | char | c | ) |

| Print a character to the console or terminal. This function prints a single character to the console. No CR/LF conversion is performed. Note: NOSCFG_FEATURE_CONOUT must be defined to 1 to have this function compiled in. See also: nosPrint, p_putchar

NANOEXT void nosPrintf1 | ( | const char * | fmt,
|  | arg | a1
| ) |

  | Print a formated character string to the console or terminal. This function acts like the usual printf function, except that it is limmited to the basic formats. The largest integer that can be displayed is of type INT_t. Parameters:
  | fmt | format string
  | a1 | first argument
Note: NOSCFG_FEATURE_CONOUT and NOSCFG_FEATURE_PRINTF must be defined to 1 to have this function compiled in. This function is not variadic. To print strings with more than one argument, you may use the functions nosPrintf2 (2 arguments) to nosPrintf6 (6 arguments). See also: nosPrintChar, nosPrint

NANOEXT void nosSPrintf1 | ( | char * | buf,
|  | const char * | fmt,
|  | arg | a1
| ) |

  | Print a formated character string to a string buffer. This function acts like the usual sprintf function, except that it is limmited to the basic formats. The largest integer that can be displayed is of type INT_t. Parameters:
  | buf | destination string buffer
  | fmt | format string
  | a1 | first argument
Note: NOSCFG_FEATURE_SPRINTF must be defined to 1 to have this function compiled in. This function is not variadic. To print strings with more than one argument, you may use the functions nosSPrintf2 (2 arguments) to nosSPrintf6 (6 arguments). See also: nosPrintf1, nosPrint

NANOEXT UVAR_t p_putchar | ( | char | c | ) |

  | Print a character to the console or terminal. This function must be supplied by the architecture port; it is not callable by the user. Parameters:
  | c | character to print out.
Returns: This function should return nonzero (=TRUE) when the character could be printed. If the function could not print the character (e.g. the FIFO of a serial line is full), this function should return zero (=FALSE). The nano layer will try to send the character later again. Note: This function must not do a CR/LF conversion, a CR must result in a simple carriage return, and a LF must result in a simple line feed without returning the carriage. If this function returns FALSE, the platform port must do a call to c_nos_putcharReady when it is ready again for accepting new characters. When NOSCFG_CONOUT_HANDSHAKE is disabled, the return value of this function is ignored. See also: c_nos_putcharReady, c_nos_keyinput