Skip to content

File syn_port_serial.h

FileList > port > syn_port_serial.h

Go to the source code of this file

Console serial port interface. More...

  • #include "../common/syn_defs.h"
  • #include <stddef.h>
  • #include <stdint.h>

Public Functions

Type Name
SYN_Status syn_port_serial_init (uint32_t baudrate)
Initialize the console serial port.
int syn_port_serial_read (uint8_t * buf, size_t max_len)
Read available bytes from the console (non-blocking).
int syn_port_serial_write (const uint8_t * data, size_t len)
Write bytes to the console.

Public Static Functions

Type Name
int syn_port_serial_read_byte (uint8_t * byte)
Read a single byte from the console (non-blocking).
int syn_port_serial_write_byte (uint8_t byte)
Write a single byte to the console.

Detailed Description

Provides the low-level byte I/O primitives for the system console. The console is a singleton — there is exactly one per project. It may be backed by a hardware UART, USB CDC, or any other byte stream.

The CLI and logging system use this interface directly — no callback wiring is needed in application code.

** **

  • write may briefly block for buffer space but must not spin indefinitely.
  • read is strictly non-blocking: returns 0 if nothing is available.

** **

For non-console UARTs (Modbus, GPS, sensors), use syn_port_uart.h which provides instance-based access to hardware UART peripherals.

Public Functions Documentation

function syn_port_serial_init

Initialize the console serial port.

SYN_Status syn_port_serial_init (
    uint32_t baudrate
) 

Parameters:

  • baudrate Desired baud rate. Pass 0 for default (or if the underlying transport ignores baud rate, e.g. USB CDC).

Returns:

SYN_OK on success.


function syn_port_serial_read

Read available bytes from the console (non-blocking).

int syn_port_serial_read (
    uint8_t * buf,
    size_t max_len
) 

Returns immediately with however many bytes are available, up to max_len. Returns 0 if no data is available. Never blocks.

Parameters:

  • buf Buffer to read into.
  • max_len Maximum bytes to read.

Returns:

Number of bytes read (0 if nothing available), or -1 on error.


function syn_port_serial_write

Write bytes to the console.

int syn_port_serial_write (
    const uint8_t * data,
    size_t len
) 

Writes up to len bytes. May briefly block if the transmit buffer is full, but must not spin indefinitely.

Parameters:

  • data Data to write.
  • len Number of bytes.

Returns:

Number of bytes actually written, or -1 on error.


Public Static Functions Documentation

function syn_port_serial_read_byte

Read a single byte from the console (non-blocking).

static inline int syn_port_serial_read_byte (
    uint8_t * byte
) 

Parameters:

  • byte [out] Received byte.

Returns:

1 if a byte was read, 0 if nothing available.


function syn_port_serial_write_byte

Write a single byte to the console.

static inline int syn_port_serial_write_byte (
    uint8_t byte
) 

Parameters:

  • byte Byte to write.

Returns:

1 on success, -1 on error.



The documentation for this class was generated from the following file src/syntropic/port/syn_port_serial.h