Data Streams

Functions for reading, writing, etc data streams. More...

Functions

zos_result_t zn_write (uint32_t handle, const void *data, uint32_t size, zos_bool_t auto_flush)
 Write data to streamSee ZentriOS Command API documentation: stream_write. More...
 
zos_result_t zn_read (uint32_t handle, void *data, uint32_t max_size, uint32_t *bytes_read)
 Read data from streamSee ZentriOS Command API documentation: stream_read. More...
 
zos_result_t zn_read_with_buffer (uint32_t handle, zos_buffer_t *buf)
 Read data from stream info zos_buffer_tThis has similar functionality as zn_read() except a zos_buffer_t is passed as an argument allowing for zero memory copies. More...
 
zos_result_t zn_close (uint32_t handle)
 Close streamSee ZentriOS Command API documentation: stream_close. More...
 
zos_result_t zn_poll (uint32_t handle, uint32_t *bytes_available)
 Poll stream for read dataThis polls the given stream and returns if it has data to be read. More...
 

Detailed Description

Functions for reading, writing, etc data streams.

Function Documentation

zos_result_t zn_close ( uint32_t  handle)

Close streamSee ZentriOS Command API documentation: stream_close.

Parameters
[in]handleHandle of stream to close (use -1 to close all streams)
Returns
zos_result_t result of api call
zos_result_t zn_poll ( uint32_t  handle,
uint32_t *  bytes_available 
)

Poll stream for read dataThis polls the given stream and returns if it has data to be read.

Parameters
[in]handleHandle of stream to poll
[out]bytes_availablePointer to hold number of bytes available to read
Returns
zos_result_t result of api call
zos_result_t zn_read ( uint32_t  handle,
void *  data,
uint32_t  max_size,
uint32_t *  bytes_read 
)

Read data from streamSee ZentriOS Command API documentation: stream_read.

Parameters
[in]handleStream handle returned by API call
[out]dataBuffer to hold read data
[in]max_sizeMaximum amount of data to read
[out]bytes_readPointer to hold actual amount of data read (set NULL if not used)
Returns
zos_result_t result of api call
zos_result_t zn_read_with_buffer ( uint32_t  handle,
zos_buffer_t buf 
)

Read data from stream info zos_buffer_tThis has similar functionality as zn_read() except a zos_buffer_t is passed as an argument allowing for zero memory copies.

Only the 'size' field of the given zos_buffer_t argument should be populated with the maximum amount of data to read. The 'data' field should be NULL. When the API call returns:

  • the 'size' field is updated with the amount of data actually read
  • the 'data' field will be populated with the data pointer (if data was available)

Example usage:

zos_buffer_t buffer =
{
.data = NULL, // data pointer is populated AFTER the API call
.size = 128 // return up to a maximum of 128 bytes
}
zn_read_with_buffer(0, &buffer); // attempt to read stream
ZOS_LOG("Bytes read: %u", buffer.size);
ZOS_LOG("Data read: %s", buffer.data);
Parameters
[in]handleStream handle returned by API call
[out]bufBuffer to hold read data
Returns
zos_result_t result of api call
zos_result_t zn_write ( uint32_t  handle,
const void *  data,
uint32_t  size,
zos_bool_t  auto_flush 
)

Write data to streamSee ZentriOS Command API documentation: stream_write.

Parameters
[in]handleStream handle returned by API call
[in]dataData to write to stream
[in]sizeSize of data in bytes to write
[in]auto_flushIf ZOS_TRUE, only flush data when the internal buffer is full, ZOS_FALSE flush the data immediately
Returns
zos_result_t result of api call