|
Z-Wave Protocol Controller Reference
|
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <errno.h>#include <unistd.h>#include <fcntl.h>#include <termios.h>#include <sys/ioctl.h>#include <sys/file.h>#include <assert.h>#include <limits.h>#include <time.h>#include <sys/time.h>#include "zwapi_serial.h"#include "sl_log.h"Macros | |
| #define | LOG_TAG "zwapi_serial" |
| #define | SERIAL_LOG |
Functions | |
| static bool | zwapi_serial_timeval_a_lt_b_milis (const struct timeval *a, const struct timeval *b, unsigned int ms) |
| Test if a is less than b + ms. More... | |
| static int | zwapi_open_serial_port (const char *serial_device_path) |
| int | zwapi_serial_init (const char *port) |
| Initialize the serial port to 115200 BAUD 8N1. More... | |
| static void | zwapi_serial_log_timestamp (const struct timeval *cur_time) |
| sl_status_t | zwapi_serial_log_to_file_enable (const char *filename) |
| Enable logging of serial data to a file. More... | |
| sl_status_t | zwapi_serial_log_to_file_disable () |
| Disable/stop logging serial data to file. 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... | |
Variables | |
| static int | serial_fd |
| FILE * | log_fd = NULL |
| static int | log_dir = 0 |
| struct timeval | last_time |
| static char | last_used_serial_port [PATH_MAX] = {0} |
| #define LOG_TAG "zwapi_serial" |
| #define SERIAL_LOG |
|
static |
Open a serial device and configure it. Returns the file descriptor associated to the device.
| void zwapi_serial_close | ( | void | ) |
De-Initialize the serial port.
aka SerialClose
| 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
| 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.
| c | buffer to store data from serial port to. |
| len | length of buffer. |
aka SerialGetBuffer
| int zwapi_serial_get_byte | ( | uint8_t * | c | ) |
Reads a byte from the serial port device.
| c | char to store data from serial port to. |
aka SerialGetByte
| int zwapi_serial_init | ( | const char * | serial_port | ) |
Initialize the serial port to 115200 BAUD 8N1.
aka SerialInit
| bool zwapi_serial_is_file_available | ( | void | ) |
Check the file descriptor for the serial device is available for I/O operations.
aka SerialCheck
|
static |
| 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.
| 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.
| filename | file to log serial trace to, log will append to this file. |
| void zwapi_serial_put_buffer | ( | uint8_t * | c, |
| int | len | ||
| ) |
Writes the content of a buffer to the serial port device.
| c | buffer with data to write to serial port. |
| len | length of data in buffer. |
aka SerialPutBuffer
| void zwapi_serial_put_byte | ( | uint8_t | c | ) |
Write a byte to serial port device.
aka SerialPutByte
| int zwapi_serial_restart | ( | void | ) |
Closes and re-initialize the last open serial port.
aka SerialRestart
|
static |
Test if a is less than b + ms.
Testing this: a < (b + ms)
| a | timeval pointer to a value |
| b | timeval pointer to b value |
| ms | time in ms to add to b |
| struct timeval last_time |
|
static |
|
static |
| FILE* log_fd = NULL |
|
static |