Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
serial_test.h File Reference
#include <errno.h>
#include <zephyr/device.h>

Go to the source code of this file.

Typedefs

typedef void(* serial_vnd_write_cb_t) (const struct device *dev, void *user_data)
 Callback called after bytes written to the virtual serial port.
 

Functions

int serial_vnd_queue_in_data (const struct device *dev, const unsigned char *data, uint32_t size)
 Queues data to be read by the virtual serial port.
 
uint32_t serial_vnd_out_data_size_get (const struct device *dev)
 Returns size of unread written data.
 
uint32_t serial_vnd_read_out_data (const struct device *dev, unsigned char *data, uint32_t size)
 Read data written to virtual serial port.
 
uint32_t serial_vnd_peek_out_data (const struct device *dev, unsigned char *data, uint32_t size)
 Peek at data written to virtual serial port.
 
void serial_vnd_set_callback (const struct device *dev, serial_vnd_write_cb_t callback, void *user_data)
 Sets the write callback on a virtual serial port.
 

Typedef Documentation

◆ serial_vnd_write_cb_t

typedef void(* serial_vnd_write_cb_t) (const struct device *dev, void *user_data)

Callback called after bytes written to the virtual serial port.

Parameters
devAddress of virtual serial port.
user_dataUser data.

Function Documentation

◆ serial_vnd_out_data_size_get()

uint32_t serial_vnd_out_data_size_get ( const struct device * dev)

Returns size of unread written data.

Parameters
devAddress of virtual serial port.
Returns
Output data size (in bytes).

◆ serial_vnd_peek_out_data()

uint32_t serial_vnd_peek_out_data ( const struct device * dev,
unsigned char * data,
uint32_t size )

Peek at data written to virtual serial port.

Reads the data without consuming it. Future calls to serial_vnd_peek_out_data() or serial_vnd_read_out_data() will return this data again. Requires CONFIG_RING_BUFFER.

Warning
Use cases involving multiple reads of the data must prevent concurrent read operations, either by preventing all readers from being preempted or by using a mutex to govern reads.
Parameters
devAddress of virtual serial port.
dataAddress of the output buffer. Cannot be NULL.
sizeData size (in bytes).
Return values
Numberof bytes written to the output buffer.

◆ serial_vnd_queue_in_data()

int serial_vnd_queue_in_data ( const struct device * dev,
const unsigned char * data,
uint32_t size )

Queues data to be read by the virtual serial port.

Warning
Use cases involving multiple writers virtual serial port must prevent concurrent write operations, either by preventing all writers from being preempted or by using a mutex to govern writes.
Parameters
devAddress of virtual serial port.
dataAddress of data.
sizeData size (in bytes).
Return values
Numberof bytes written.

◆ serial_vnd_read_out_data()

uint32_t serial_vnd_read_out_data ( const struct device * dev,
unsigned char * data,
uint32_t size )

Read data written to virtual serial port.

Consumes the data, such that future calls to serial_vnd_read_out_data() will not include this data. Requires CONFIG_RING_BUFFER.

Warning
Use cases involving multiple reads of the data must prevent concurrent read operations, either by preventing all readers from being preempted or by using a mutex to govern reads.
Parameters
devAddress of virtual serial port.
dataAddress of the output buffer. Can be NULL to discard data.
sizeData size (in bytes).
Return values
Numberof bytes written to the output buffer.

◆ serial_vnd_set_callback()

void serial_vnd_set_callback ( const struct device * dev,
serial_vnd_write_cb_t callback,
void * user_data )

Sets the write callback on a virtual serial port.

Parameters
devAddress of virtual serial port.
callbackFunction to call after each write to the port.
user_dataOpaque data to pass to the callback.