libicsc  1.0.0
 All Data Structures Files Functions Modules
Data Structures | Macros | Typedefs | Functions
icsc.h File Reference

C libray for ICSC communication. More...

#include <stdint.h>
#include <termios.h>
#include <sys/types.h>
#include <pthread.h>
Include dependency graph for icsc.h:

Go to the source code of this file.

Data Structures

struct  icsc_t
 
struct  icsc_command
 

Macros

#define ICSC_BROADCAST   0x00
 
#define ICSC_CMD_SYS   0x1F
 
#define ICSC_SYS_PING   0x05
 
#define ICSC_SYS_PONG   0x06
 
#define ICSC_SYS_QSTAT   0x07
 
#define ICSC_SYS_RSTAT   0x08
 
#define ICSC_SYS_RELAY   0x09
 
#define SOH   1
 
#define STX   2
 
#define ETX   3
 
#define EOT   4
 
#define ICSC_SOH_START_COUNT   1
 
#define ICSC_GPIO_OUTPUT   0
 
#define ICSC_GPIO_INPUT   1
 
#define ICSC_CATCH_ALL   0xFF
 

Typedefs

typedef struct icsc_command command_t
 
typedef struct icsc_commandcommand_ptr
 
typedef struct icsc_ticsc_ptr
 
typedef void(* callbackFunction )(icsc_ptr, unsigned char, char, unsigned char, char *)
 

Functions

int icsc_gpio_open (int num, int mode)
 Open a GPIO device in either input or output mode. Exports the GPIO node. More...
 
int icsc_gpio_read (int num)
 Read the value of a GPIO. More...
 
int icsc_gpio_write (int num, int level)
 Set a GPIO to high or low. More...
 
int icsc_gpio_close (int num)
 Close a GPIO. Unexports the GPIO node. More...
 
int icsc_serial_open (const char *path, unsigned long baud)
 Open a serial device at a specific baud rate. More...
 
int icsc_serial_wait_available (int fd, unsigned long timeout)
 Wait for serial data to arrive up until the timeout expires. More...
 
int icsc_serial_available (int fd)
 Look to see if serial data is available. More...
 
int icsc_serial_read (int fd)
 Read a byte from the serial port. More...
 
void icsc_serial_flush (int fd)
 Wait until all data sent to the serial port has been delivered to the wire. More...
 
int icsc_serial_write (int fd, uint8_t c)
 Write a byte to a serial port. More...
 
void icsc_serial_close (int fd)
 Close the serial port. More...
 
int icsc_register_command (icsc_ptr icsc, char command, callbackFunction func)
 Register a new command callback. More...
 
int icsc_unregister_command (icsc_ptr icsc, char command)
 Unregister an old command character. More...
 
icsc_ptr icsc_init_de (const char *uart, unsigned long baud, uint8_t station, int de)
 Create a new ICSC context, initialize the hardware, and start listening for messages. More...
 
icsc_ptr icsc_init (const char *uart, unsigned long baud, uint8_t station)
 Create a new ICSC context, initialize the hardware, and start listening for messages. More...
 
int icsc_close (icsc_ptr icsc)
 Close an ICSC instance freeing the memory. Terminates all communication. More...
 
int icsc_send_array (icsc_ptr icsc, uint8_t station, char command, uint8_t len, const char *data)
 Send an array of data (or struct as if it were an array) to a remote station. More...
 
int icsc_send_string (icsc_ptr icsc, uint8_t station, char command, const char *str)
 Send a text string to a remote station. More...
 
int icsc_send_long (icsc_ptr icsc, uint8_t station, char command, int32_t data)
 Send a 32-bit integer to a remote station. More...
 
int icsc_send_int (icsc_ptr icsc, uint8_t station, char command, int16_t data)
 Send a 16-bit integer to a remote station. More...
 
int icsc_send_char (icsc_ptr icsc, uint8_t station, char command, int8_t data)
 Send an 8-bit integer to a remote station. More...
 
int icsc_broadcast_array (icsc_ptr icsc, char command, uint8_t len, const char *data)
 Send an array of data (or struct as if it were an array) to all stations. More...
 
int icsc_broadcast_string (icsc_ptr icsc, char command, const char *str)
 Send a text string to all remote stations. More...
 
int icsc_broadcast_long (icsc_ptr icsc, char command, int32_t data)
 Send a 32-bit integer to all remote stations. More...
 
int icsc_broadcast_int (icsc_ptr icsc, char command, int16_t data)
 Send a 16-bit integer to all remote stations. More...
 
int icsc_broadcast_char (icsc_ptr icsc, char command, int8_t data)
 Send an 8-bit integer to all remote stations. More...
 
void icsc_enable_debug ()
 Enable debug messages. More...
 
void icsc_disable_debug ()
 Disable debug messages. More...
 
void icsc_debug (const char *fmt,...)
 Display a debug message to stderr. More...
 
void icsc_error (const char *fmt,...)
 Display an error message to stderr. More...
 

Detailed Description

C libray for ICSC communication.