CardSight 0.1.0
C API reference for the CardSight firmware and application
Loading...
Searching...
No Matches
console.h File Reference

The console stream the log, the shell and the C library's stdout share. More...

#include <stddef.h>

Go to the source code of this file.

Functions

void console_write (const char *data, size_t length)
 Write bytes to the console.
int console_read (int timeout_ms)
 Read one byte from the console.
int console_start_receive (void)
 Start interrupt-driven console input.

Detailed Description

The console stream the log, the shell and the C library's stdout share.

Function Documentation

◆ console_read()

int console_read ( int timeout_ms)

Read one byte from the console.

Parameters
timeout_msMilliseconds to wait for input.
Returns
The byte value (0 to 255), -EAGAIN after timeout_ms milliseconds, or -ENODEV when the receive side has not been started.

◆ console_start_receive()

int console_start_receive ( void )

Start interrupt-driven console input.

Creates the receive queue and connects the UART interrupt, so the receive side needs the kernel; call once the scheduler runs.

Returns
0 on success, -ENODEV without a configured UART, -ENOMEM without queue memory, or -EINVAL when the interrupt cannot be connected.

◆ console_write()

void console_write ( const char * data,
size_t length )

Write bytes to the console.

Each newline is preceded by a carriage return so a terminal returns to column zero, then the byte is sent synchronously to the UART.

Parameters
dataBytes to write; may contain any value.
lengthNumber of bytes in data.