IO Stream

Description

IO Stream.

Overview

IO Stream is a platform module software that provides Input/Output functionalities by creating streams. Streams are abstractions allowing a uniform way to read/write data regardless of the physical communication interface.

IO Stream offers many interfaces, see submodules for a list of all types available and their specificities.You can load multiple streams in the project and you can select the interface that must be used at runtime.Some interface type can also be instantiated, meaning that you can have multiple instances of an interface type which will be normally bound to a hardware peripheral.

Initialization

The IO Stream core doesn't require any initialization. Instead each stream type has their own initialization and their own configuration. See IO Stream specific type to know more about how to initialize a stream.

Note that most stream will set itself as the default stream during their initialization. Thus the initial default stream will be the last stream initialized.

Default system-wide stream

Multiple streams can be initialized in your application and you can configure a default stream that must be used when no stream is specified. Also note that the default stream will be used when calling printf and you can change the default stream at runtime. The following defines should be used for the default stream:

SL_IOSTREAM_STDIN SL_IOSTREAM_STDOUT SL_IOSTREAM_STDERR

RTOS - Task's default stream

In the case of an RTOS environment, each task can set its own stream. By default, the task stream will be set to the system_wide default stream. From your task, you can change the default stream assigned to your task without affecting the other tasks' stream.

Printf

IO Stream provides third-party printf integrations. It can work with toolchain implementation or with the tiny printf implementation for embedded system. The printf API doesn't have an argument for specifying the stream to be used, so IO Stream provides a printf API that takes a stream as an argument and calls the configured third-party implementation of printf.

Modules

IO Stream EUSART
IO Stream EUSART.
 
IO Stream LEUART
IO Stream LEUART.
 
IO Stream RTT
IO Stream RTT.
 
IO Stream STDLIB Configuration
IO Stream STDLIB Configuration.
 
IO Stream SWO
IO Stream SWO.
 
IO Stream UART
IO Stream UART.
 
IO Stream USART
IO Stream USART.
 

Data Structures

struct  sl_iostream_t
 Struct representing iostream operations.
 
struct  sl_iostream_instance_info_t
 Struct representing an IO Stream instance.
 

Functions

sl_status_t sl_iostream_set_default (sl_iostream_t *stream)
 Set the stream as default IO Stream.
 
sl_iostream_tsl_iostream_get_default (void)
 Get the default IO Stream configured.
 
sl_status_t sl_iostream_set_system_default (sl_iostream_t *stream)
 Configure the systemwide default stream.
 
sl_status_t sl_iostream_write (sl_iostream_t *stream, const void *buffer, size_t buffer_length)
 Output data on a stream.
 
sl_status_t sl_iostream_read (sl_iostream_t *stream, void *buffer, size_t buffer_length, size_t *bytes_read)
 Get data from a stream.
 
sl_status_t sl_iostream_putchar (sl_iostream_t *stream, char c)
 Print a character on stream.
 
sl_status_t sl_iostream_getchar (sl_iostream_t *stream, char *c)
 Print a character on stream.
 
sl_status_t sl_iostream_printf (sl_iostream_t *stream, const char *format,...)
 Print a formated string on stream.
 

Enumerations

enum  sl_iostream_type_t {
  SL_IOSTREAM_TYPE_SWO = 0,
  SL_IOSTREAM_TYPE_RTT = 1,
  SL_IOSTREAM_TYPE_UART = 2,
  SL_IOSTREAM_TYPE_VUART = 3,
  SL_IOSTREAM_TYPE_DEBUG_OUTPUT = 4,
  SL_IOSTREAM_TYPE_LOOPBACK = 5,
  SL_IOSTREAM_TYPE_UNDEFINED = 6
}
 Enumeration representing the possible types of iostream instances.
 

Function Documentation

◆ sl_iostream_set_default()

sl_status_t sl_iostream_set_default ( sl_iostream_t stream)

Set the stream as default IO Stream.

Parameters
[in]streamIO Stream to set as default.
Returns
Status result

◆ sl_iostream_get_default()

sl_iostream_t* sl_iostream_get_default ( void  )

Get the default IO Stream configured.

Returns
Status result

◆ sl_iostream_set_system_default()

sl_status_t sl_iostream_set_system_default ( sl_iostream_t stream)

Configure the systemwide default stream.

Parameters
[in]streamIO Stream to be used.
Returns
Status result

◆ sl_iostream_write()

sl_status_t sl_iostream_write ( sl_iostream_t stream,
const void *  buffer,
size_t  buffer_length 
)

Output data on a stream.

Parameters
[in]streamIO Stream to be used. SL_IOSTREAM_STDOUT; Default output stream will be used. Pointer to specific stream; Specific stream will be used.
[in]bufferBuffer that contains the data to output.
[in]buffer_lengthData length contained in the buffer.
Returns
Status result

◆ sl_iostream_read()

sl_status_t sl_iostream_read ( sl_iostream_t stream,
void *  buffer,
size_t  buffer_length,
size_t *  bytes_read 
)

Get data from a stream.

Parameters
[in]streamIO Stream to be used. SL_IOSTREAM_STDOUT; Default output stream will be used. Pointer to specific stream; Specific stream will be used.
[out]bufferBuffer that contains the data to output.
[in]buffer_lengthData length contained in the buffer.
[out]bytes_readData length copied to the buffer.
Returns
Status result

◆ sl_iostream_putchar()

sl_status_t sl_iostream_putchar ( sl_iostream_t stream,
char 
)

Print a character on stream.

Parameters
[in]streamIO Stream to be used: SL_IOSTREAM_STDOUT; Default output stream will be used. SL_IOSTREAM_STDERR; Default error output stream will be used. Pointer to specific stream; Specific stream will be used.
[in]cCharacter to print
Returns
Status result

◆ sl_iostream_getchar()

sl_status_t sl_iostream_getchar ( sl_iostream_t stream,
char * 
)

Print a character on stream.

Parameters
[in]streamIO Stream to be used. SL_IOSTREAM_STDIN; Default input stream will be used. Pointer to specific stream; Specific stream will be used.
[out]cPointer to variable that will receive the character.
Returns
Status result

◆ sl_iostream_printf()

sl_status_t sl_iostream_printf ( sl_iostream_t stream,
const char *  format,
  ... 
)

Print a formated string on stream.

Parameters
[in]streamIO Stream to be used: SL_IOSTREAM_STDOUT; Default output stream will be used. SL_IOSTREAM_STDERR; Default error output stream will be used. Pointer to specific stream; Specific stream will be used.
[in]formatString that contains the text to be written.
[in]...Additional arguments.
Returns
Status result

Enumeration Type Documentation

◆ sl_iostream_type_t

Enumeration representing the possible types of iostream instances.

Enumerator
SL_IOSTREAM_TYPE_SWO 

SWO Instance.

SL_IOSTREAM_TYPE_RTT 

RTT Instance.

SL_IOSTREAM_TYPE_UART 

USART Instance.

SL_IOSTREAM_TYPE_VUART 

Vuart.

SL_IOSTREAM_TYPE_DEBUG_OUTPUT 

Backchannel output Instance Type.

SL_IOSTREAM_TYPE_LOOPBACK 

Loopback Instance.

SL_IOSTREAM_TYPE_UNDEFINED 

Undefined Instance Type.