Wiicom API Lib
|
Compact module function library. Continua...
Definizioni | |
#define | MAXBUFFER_RECIV_CMD |
#define | WIICOM_CMD_MSG_HEAD1 'S' |
#define | WIICOM_CMD_MSG_HEAD2 'T' |
#define | WIICOM_CMD_MSG_TERM1 'E' |
#define | WIICOM_CMD_MSG_TERM2 'N' |
#define | WIICOM_CMD_HEADER_SIZE 9 |
#define | WIICOM_CMD_TERMINATOR_SIZE 4 |
#define | WIICOM_DIO_MAX 4 |
Funzioni | |
void | wiicom_comm_reset (int8_t b_reset_all, t_wiicom_comm_msg *cmd_msg) |
Function that cleans up the data communication structure. Continua... | |
void | wiicom_comm_print (FILE *fp, t_wiicom_comm_msg *cmd_msg) |
Function that prints the contents of the communication data structure. Continua... | |
void | wiicom_comm_elab (uint8_t *rxData, uint32_t num_rxData, t_wiicom_comm_msg *cmd_msg, void(*callback)(t_wiicom_comm_msg *), void(*callback_error)(t_wiicom_comm_msg *)) |
Function that extracts datas from a buffer messages/commands sent by your Compact module. Continua... | |
void | wiicom_comm_createCommand (t_wiicom_comm_msg *cmd_msg, uint16_t par_msg_cnt, uint8_t par_destination, uint16_t par_action) |
Function that initializes the communication data structure for send a new command to a Compact module. Continua... | |
uint8_t | wiicom_comm_addToDataBlock (t_wiicom_comm_msg *cmd_msg, uint16_t par_type, uint8_t par_data_cnt, uint8_t par_data_idx, uint8_t *par_data) |
Function that adds a datablock to a given communication data structure. Continua... | |
void | wiicom_comm_closeCommand (t_wiicom_comm_msg *cmd_msg) |
Function which finalizes the communication data structure, the command is ready to be sent to your Compact. Continua... | |
uint8_t | wiicom_comm_getDataBlock (t_wiicom_comm_msg *cmd_msg, uint16_t par_type, uint8_t par_data_cnt, uint8_t par_data_idx, uint8_t *par_data) |
Function that extracts a datablock from communication data structure. Continua... | |
void | wiicom_comm_cmd_msgTOrow (t_wiicom_comm_msg *cmd_msg, uint8_t *rowData, uint16_t *rowData_length) |
Function that converts the content of a communication data structure in a sequence of bytes. Continua... | |
uint8_t | wiicom_comm_recivIScomplete (t_wiicom_comm_msg *cmd_msg) |
function that checks if a command/message has been received completely Continua... | |
uint8_t | wiicom_comm_sendCommand (t_wiicom_comm_msg *cmd_msg, const char *ip, uint16_t port) |
Function that sends a command to a Compact module and, if provided, returns the response. Continua... | |
uint8_t | wiicom_comm_sendCommand_socket (t_wiicom_comm_msg *cmd_msg, int socketfd) |
Function that sends a command to a Compact module on pre-open socket and, if provided, returns the response. Continua... | |
uint8_t | wiicom_comm_get_compact_info (const char *ip, uint16_t port, t_wiicom_comm_compact_info *info_struct) |
Function that read Compact module information. Continua... | |
uint8_t | wiicom_comm_set_compact_alias (const char *ip, uint16_t port, char *alias) |
Function that set Compact module alias. Continua... | |
uint8_t | wiicom_comm_get_compact_uart (const char *ip, uint16_t port, t_wiicom_comm_compact_uart *uart_struct) |
Function that read Compact module UART configuration. Continua... | |
uint8_t | wiicom_comm_set_compact_uart (const char *ip, uint16_t port, t_wiicom_comm_compact_uart *uart_struct) |
Function that set Compact module UART configuration. Continua... | |
uint8_t | wiicom_comm_get_compact_net (const char *ip, uint16_t port, t_wiicom_comm_compact_net *net_struct) |
Function that read Compact module network configuration. Continua... | |
uint8_t | wiicom_comm_set_compact_net (const char *ip, uint16_t port, t_wiicom_comm_compact_net *net_struct) |
Function that set Compact module network configuration. Continua... | |
uint8_t | wiicom_comm_get_compact_dio (const char *ip, uint16_t port, uint8_t num_dio, uint8_t *b_enabled, uint8_t *type) |
uint8_t | wiicom_comm_set_compact_dio (const char *ip, uint16_t port, uint8_t num_dio, uint8_t b_enabled, uint8_t type) |
uint8_t | wiicom_comm_get_compact_canbus (const char *ip, uint16_t port, uint32_t *speed, uint8_t *output_type, uint8_t *input_type) |
uint8_t | wiicom_comm_set_compact_canbus (const char *ip, uint16_t port, uint32_t speed, uint8_t output_type, uint8_t input_type) |
uint8_t | wiicom_comm_sendMsgCanbus (const char *ip, uint16_t port, uint32_t idmsg, uint8_t b_extendedMsg, uint8_t dlc, uint8_t *data) |
uint8_t | wiicom_comm_sendMsgCanbus_socket (int socketfd, uint32_t idmsg, uint8_t b_extendedMsg, uint8_t dlc, uint8_t *data) |
uint8_t | wiicom_comm_parseMsgCanbus (const char *recivData, uint16_t recivedDataLength, uint32_t *idmsg, uint8_t *b_extendedMsg, uint8_t *dlc, uint8_t *data) |
Variabili | |
const t_dtype_size | CMD_DTYPE_SIZE [] |
Array containing the length of each data type t_wiicom_cmd_data_type and the max data count The length of a data type can be obtained by: CMD_DTYPE_SIZE[CMD_DTYPE_IPADDR].bytes_size The result obtained in this example is 4 The max data count of a data type can be obtained by: CMD_DTYPE_SIZE[CMD_DTYPE_IPADDR].max_data_count The result obtained in this example is 1. Continua... | |
Compact module function library.
A library that allows you to communicate with the Wiicom Compact modules
#define MAXBUFFER_RECIV_CMD |
#define WIICOM_CMD_HEADER_SIZE 9 |
#define WIICOM_CMD_MSG_HEAD1 'S' |
#define WIICOM_CMD_MSG_HEAD2 'T' |
#define WIICOM_CMD_MSG_TERM1 'E' |
#define WIICOM_CMD_MSG_TERM2 'N' |
#define WIICOM_CMD_TERMINATOR_SIZE 4 |
#define WIICOM_DIO_MAX 4 |
uint8_t wiicom_comm_addToDataBlock | ( | t_wiicom_comm_msg * | cmd_msg, |
uint16_t | par_type, | ||
uint8_t | par_data_cnt, | ||
uint8_t | par_data_idx, | ||
uint8_t * | par_data | ||
) |
Function that adds a datablock to a given communication data structure.
[in,out] | cmd_msg | communication structure to add a given datablock |
[in] | par_type | type of data added |
[in] | par_data_cnt | data vector number elements to be add; set it only for vector data type, otherwise 1 |
[in] | par_data_idx | data vector index (zero based start index); set it only for vector data type, otherwise 0 |
[in] | par_data | buffer containing the data to be added |
void wiicom_comm_closeCommand | ( | t_wiicom_comm_msg * | cmd_msg | ) |
Function which finalizes the communication data structure, the command is ready to be sent to your Compact.
[in,out] | cmd_msg | communication data structure to be finalized |
void wiicom_comm_cmd_msgTOrow | ( | t_wiicom_comm_msg * | cmd_msg, |
uint8_t * | rowData, | ||
uint16_t * | rowData_length | ||
) |
Function that converts the content of a communication data structure in a sequence of bytes.
[in] | cmd_msg | communication data structure on which you want to perform the conversion |
[out] | rowData | that will contain the binary conversion of the communication data structure |
[out] | rowData_length | that will contain the bytes length of binary conversion |
void wiicom_comm_createCommand | ( | t_wiicom_comm_msg * | cmd_msg, |
uint16_t | par_msg_cnt, | ||
uint8_t | par_destination, | ||
uint16_t | par_action | ||
) |
Function that initializes the communication data structure for send a new command to a Compact module.
[in,out] | cmd_msg | command data structure to be initialized |
[in] | par_msg_cnt | number of the message to be sent |
[in] | par_destination | number that identifies the recipient |
[in] | par_action | action that is required to be performed by the Compact module |
void wiicom_comm_elab | ( | uint8_t * | rxData, |
uint32_t | num_rxData, | ||
t_wiicom_comm_msg * | cmd_msg, | ||
void(*)(t_wiicom_comm_msg *) | callback, | ||
void(*)(t_wiicom_comm_msg *) | callback_error | ||
) |
Function that extracts datas from a buffer messages/commands sent by your Compact module.
[in] | rxData | buffer containing the messages/commands to be interpreted |
[in] | num_rxData | number of bytes to interpret |
[in,out] | cmd_msg | communication data structure to populate |
[in] | callback | function is invoked when a valid command is extracted from the buffer Caution: If set to NULL will not be executed |
[in] | callback_error | function is invoked when an error occurred on extraction of a command from the buffer Caution: If set to NULL will not be executed |
uint8_t wiicom_comm_get_compact_canbus | ( | const char * | ip, |
uint16_t | port, | ||
uint32_t * | speed, | ||
uint8_t * | output_type, | ||
uint8_t * | input_type | ||
) |
uint8_t wiicom_comm_get_compact_dio | ( | const char * | ip, |
uint16_t | port, | ||
uint8_t | num_dio, | ||
uint8_t * | b_enabled, | ||
uint8_t * | type | ||
) |
uint8_t wiicom_comm_get_compact_info | ( | const char * | ip, |
uint16_t | port, | ||
t_wiicom_comm_compact_info * | info_struct | ||
) |
Function that read Compact module information.
[in] | ip | module IP address |
[in] | port | module port |
[out] | info_struct | info data structure that will contain Compact module information |
uint8_t wiicom_comm_get_compact_net | ( | const char * | ip, |
uint16_t | port, | ||
t_wiicom_comm_compact_net * | net_struct | ||
) |
Function that read Compact module network configuration.
[in] | ip | module IP address |
[in] | port | module port |
[out] | net_struct | network configuration data structure that will contain Compact module network config |
uint8_t wiicom_comm_get_compact_uart | ( | const char * | ip, |
uint16_t | port, | ||
t_wiicom_comm_compact_uart * | uart_struct | ||
) |
Function that read Compact module UART configuration.
[in] | ip | module IP address |
[in] | port | module port |
[out] | uart_struct | UART configuration data structure that will contain Compact module UART config |
uint8_t wiicom_comm_getDataBlock | ( | t_wiicom_comm_msg * | cmd_msg, |
uint16_t | par_type, | ||
uint8_t | par_data_cnt, | ||
uint8_t | par_data_idx, | ||
uint8_t * | par_data | ||
) |
Function that extracts a datablock from communication data structure.
[in] | cmd_msg | communication data structure from which you want to extract datablock |
[in] | par_type | type of data to be extracted |
[in] | par_data_cnt | data vector number elements to be extracted, otherwise 1 |
[in] | par_data_idx | data vector index (zero based start index); it sets only for vector data type, otherwise 0 |
[out] | par_data | it contains the data extracted |
uint8_t wiicom_comm_parseMsgCanbus | ( | const char * | recivData, |
uint16_t | recivedDataLength, | ||
uint32_t * | idmsg, | ||
uint8_t * | b_extendedMsg, | ||
uint8_t * | dlc, | ||
uint8_t * | data | ||
) |
void wiicom_comm_print | ( | FILE * | fp, |
t_wiicom_comm_msg * | cmd_msg | ||
) |
Function that prints the contents of the communication data structure.
[in] | fp | pointer files on which to perform printing of the data |
[in] | cmd_msg | communication data structure that you want to print |
uint8_t wiicom_comm_recivIScomplete | ( | t_wiicom_comm_msg * | cmd_msg | ) |
function that checks if a command/message has been received completely
[in] | cmd_msg | communication data structure on which you want to perform the check |
void wiicom_comm_reset | ( | int8_t | b_reset_all, |
t_wiicom_comm_msg * | cmd_msg | ||
) |
Function that cleans up the data communication structure.
[in] | b_reset_all | if set to TRUE cleans the entire structure, if FALSE only the data it contains leaving unchanged the accessories data used internally for the operations of command decoding |
[in,out] | cmd_msg | communication data structure to clean |
uint8_t wiicom_comm_sendCommand | ( | t_wiicom_comm_msg * | cmd_msg, |
const char * | ip, | ||
uint16_t | port | ||
) |
Function that sends a command to a Compact module and, if provided, returns the response.
[in,out] | cmd_msg | communication data structure to be sent to your Compact, after sending the structure will contain the answer of your Compact |
[in] | ip | module IP address to send the command |
[in] | port | Module port to send the command |
uint8_t wiicom_comm_sendCommand_socket | ( | t_wiicom_comm_msg * | cmd_msg, |
int | socketfd | ||
) |
Function that sends a command to a Compact module on pre-open socket and, if provided, returns the response.
[in,out] | cmd_msg | communication data structure to be sent to your Compact, after sending the structure will contain the answer of your Compact |
[in] | socketfd | a file descriptor for the socket |
uint8_t wiicom_comm_sendMsgCanbus | ( | const char * | ip, |
uint16_t | port, | ||
uint32_t | idmsg, | ||
uint8_t | b_extendedMsg, | ||
uint8_t | dlc, | ||
uint8_t * | data | ||
) |
uint8_t wiicom_comm_sendMsgCanbus_socket | ( | int | socketfd, |
uint32_t | idmsg, | ||
uint8_t | b_extendedMsg, | ||
uint8_t | dlc, | ||
uint8_t * | data | ||
) |
uint8_t wiicom_comm_set_compact_alias | ( | const char * | ip, |
uint16_t | port, | ||
char * | alias | ||
) |
Function that set Compact module alias.
[in] | ip | module IP address |
[in] | port | module port |
[in] | alias | string that contain the new Compact module alias |
uint8_t wiicom_comm_set_compact_canbus | ( | const char * | ip, |
uint16_t | port, | ||
uint32_t | speed, | ||
uint8_t | output_type, | ||
uint8_t | input_type | ||
) |
uint8_t wiicom_comm_set_compact_dio | ( | const char * | ip, |
uint16_t | port, | ||
uint8_t | num_dio, | ||
uint8_t | b_enabled, | ||
uint8_t | type | ||
) |
uint8_t wiicom_comm_set_compact_net | ( | const char * | ip, |
uint16_t | port, | ||
t_wiicom_comm_compact_net * | net_struct | ||
) |
Function that set Compact module network configuration.
[in] | ip | module IP address |
[in] | port | module port |
[in] | net_struct | network configuration data structure that will be set on Compact module |
uint8_t wiicom_comm_set_compact_uart | ( | const char * | ip, |
uint16_t | port, | ||
t_wiicom_comm_compact_uart * | uart_struct | ||
) |
Function that set Compact module UART configuration.
[in] | ip | module IP address |
[in] | port | module port |
[in] | uart_struct | UART configuration data structure that will be set on Compact module |
const t_dtype_size CMD_DTYPE_SIZE[] |
Array containing the length of each data type t_wiicom_cmd_data_type and the max data count The length of a data type can be obtained by: CMD_DTYPE_SIZE[CMD_DTYPE_IPADDR].bytes_size The result obtained in this example is 4 The max data count of a data type can be obtained by: CMD_DTYPE_SIZE[CMD_DTYPE_IPADDR].max_data_count The result obtained in this example is 1.
uint8_t input |
uint8_t output |
uint8_t prseg |
uint8_t sam |
uint8_t seg1ph |
uint8_t seg2ph |
uint8_t sjw |
uint32_t speed |