Z-Wave Protocol Controller Reference
zwapi_serial.h File Reference

Serial Port API for the Z-Wave module. Used for low level read/write functions to the serial port. More...

#include <stdint.h>
#include <stdbool.h>
#include "sl_status.h"
Include dependency graph for zwapi_serial.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int zwapi_serial_init (const char *serial_port)
 Initialize the serial port to 115200 BAUD 8N1. More...
 
void zwapi_serial_close (void)
 De-Initialize the serial port. More...
 
int zwapi_serial_restart (void)
 Closes and re-initialize the last open serial port. More...
 
int zwapi_serial_get_byte (uint8_t *c)
 Reads a byte from the serial port device. More...
 
void zwapi_serial_put_byte (uint8_t c)
 Write a byte to serial port device. More...
 
int zwapi_serial_get_buffer (uint8_t *c, int len)
 Reads the output of the serial port device and stores the content in a buffer. More...
 
void zwapi_serial_put_buffer (uint8_t *c, int len)
 Writes the content of a buffer to the serial port device. More...
 
bool zwapi_serial_is_file_available (void)
 Check the file descriptor for the serial device is available for I/O operations. More...
 
void zwapi_serial_drain_buffer (void)
 Flush the serial output if using buffered output. More...
 
sl_status_t zwapi_serial_log_to_file_disable ()
 Disable/stop logging serial data to file. More...
 
sl_status_t zwapi_serial_log_to_file_enable (const char *filename)
 Enable logging of serial data to a file. More...
 

Detailed Description

Serial Port API for the Z-Wave module. Used for low level read/write functions to the serial port.

Function Documentation

◆ zwapi_serial_close()

void zwapi_serial_close ( void  )

De-Initialize the serial port.

aka SerialClose

Here is the caller graph for this function:

◆ zwapi_serial_drain_buffer()

void zwapi_serial_drain_buffer ( void  )

Flush the serial output if using buffered output.

This function calls tcdrain, which waits that the TTY buffer data has been written to the hardware.

aka SerialFlush

Here is the caller graph for this function:

◆ zwapi_serial_get_buffer()

int zwapi_serial_get_buffer ( uint8_t *  c,
int  len 
)

Reads the output of the serial port device and stores the content in a buffer.

Parameters
cbuffer to store data from serial port to.
lenlength of buffer.
Returns
The length of the data copied in the buffer.

aka SerialGetBuffer

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_get_byte()

int zwapi_serial_get_byte ( uint8_t *  c)

Reads a byte from the serial port device.

Parameters
cchar to store data from serial port to.
Returns
0 if no characters are available, otherwise this returns 1 (length of the read data)

aka SerialGetByte

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_init()

int zwapi_serial_init ( const char *  serial_port)

Initialize the serial port to 115200 BAUD 8N1.

Returns
the file descriptor for the serial device.

aka SerialInit

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_is_file_available()

bool zwapi_serial_is_file_available ( void  )

Check the file descriptor for the serial device is available for I/O operations.

Returns
true if the file is available, false if not or if an error occurred.

aka SerialCheck

Here is the caller graph for this function:

◆ zwapi_serial_log_to_file_disable()

sl_status_t zwapi_serial_log_to_file_disable ( )

Disable/stop logging serial data to file.

This will stop the logging of serial data to file.

Returns
SL_STATUS_OK on success
Here is the caller graph for this function:

◆ zwapi_serial_log_to_file_enable()

sl_status_t zwapi_serial_log_to_file_enable ( const char *  filename)

Enable logging of serial data to a file.

The log will append to the file, it is up to the user to handle log rotation, free disk space monitoring etc.

Parameters
filenamefile to log serial trace to, log will append to this file.
Returns
SL_STATUS_OK on success.
SL_STATUS_ALREADY_INITIALIZED if log to file is already enabled.
SL_STATUS_FAIL if other failure (e.g. folder doesn't exist, lacking permissions, etc.).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_put_buffer()

void zwapi_serial_put_buffer ( uint8_t *  c,
int  len 
)

Writes the content of a buffer to the serial port device.

Parameters
cbuffer with data to write to serial port.
lenlength of data in buffer.

aka SerialPutBuffer

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_put_byte()

void zwapi_serial_put_byte ( uint8_t  c)

Write a byte to serial port device.

aka SerialPutByte

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwapi_serial_restart()

int zwapi_serial_restart ( void  )

Closes and re-initialize the last open serial port.

Returns
the file descriptor for the serial device.

aka SerialRestart

Here is the call graph for this function:
Here is the caller graph for this function: