Wiicom API Lib
 Tutto Strutture dati File Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Definizioni Gruppi
Riferimenti per il file C:/WIICOM-SVN/Sviluppo/Software/library/wiicom_lib/trunk/wiicom_libcommunication.c

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
 

Tipi enumerati (enum)

enum  t_wiicom_cmd_msg_step_elab {
  CMD_STEP_RECV_START, CMD_STEP_RECV_HEAD1, CMD_STEP_RECV_HEAD2, CMD_STEP_RECV_MSGCNT1,
  CMD_STEP_RECV_MSGCNT2, CMD_STEP_RECV_DEST, CMD_STEP_RECV_DATALEN1, CMD_STEP_RECV_DATALEN2,
  CMD_STEP_RECV_ACTION1, CMD_STEP_RECV_ACTION2, CMD_STEP_RECV_DATA, CMD_STEP_RECV_CRC1,
  CMD_STEP_RECV_CRC2, CMD_STEP_RECV_TERM1, CMD_STEP_RECV_TERM2, CMD_STEP_RECV_END
}
 

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...
 

Descrizione dettagliata

Compact module function library.

A library that allows you to communicate with the Wiicom Compact modules

Autore
Marco Malano
WIICOM s.r.l
Versione
1.1.0
Data
2012
Attenzione
This library depends on wiicom_libutil and on wiicom_libsocket
Every function that expects a result, in case of an error, set the Wiicom errno and print to stderr the error occurred.
Nota
None.

Documentazione delle definizioni

#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

Documentazione dei tipi enumerati

Valori del tipo enumerato
CMD_STEP_RECV_START 
CMD_STEP_RECV_HEAD1 
CMD_STEP_RECV_HEAD2 
CMD_STEP_RECV_MSGCNT1 
CMD_STEP_RECV_MSGCNT2 
CMD_STEP_RECV_DEST 
CMD_STEP_RECV_DATALEN1 
CMD_STEP_RECV_DATALEN2 
CMD_STEP_RECV_ACTION1 
CMD_STEP_RECV_ACTION2 
CMD_STEP_RECV_DATA 
CMD_STEP_RECV_CRC1 
CMD_STEP_RECV_CRC2 
CMD_STEP_RECV_TERM1 
CMD_STEP_RECV_TERM2 
CMD_STEP_RECV_END 

Documentazione delle funzioni

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.

Parametri
[in,out]cmd_msgcommunication structure to add a given datablock
[in]par_typetype of data added
[in]par_data_cntdata vector number elements to be add; set it only for vector data type, otherwise 1
[in]par_data_idxdata vector index (zero based start index); set it only for vector data type, otherwise 0
[in]par_databuffer containing the data to be added
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in,out]cmd_msgcommunication data structure to be finalized
Restituisce
void
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.

Parametri
[in]cmd_msgcommunication data structure on which you want to perform the conversion
[out]rowDatathat will contain the binary conversion of the communication data structure
[out]rowData_lengththat will contain the bytes length of binary conversion
Restituisce
void
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.

Parametri
[in,out]cmd_msgcommand data structure to be initialized
[in]par_msg_cntnumber of the message to be sent
[in]par_destinationnumber that identifies the recipient
[in]par_actionaction that is required to be performed by the Compact module
Restituisce
void
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.

Parametri
[in]rxDatabuffer containing the messages/commands to be interpreted
[in]num_rxDatanumber of bytes to interpret
[in,out]cmd_msgcommunication data structure to populate
[in]callbackfunction is invoked when a valid command is extracted from the buffer
Caution: If set to NULL will not be executed
[in]callback_errorfunction is invoked when an error occurred on extraction of a command from the buffer
Caution: If set to NULL will not be executed
Restituisce
void
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.

Parametri
[in]ipmodule IP address
[in]portmodule port
[out]info_structinfo data structure that will contain Compact module information
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]ipmodule IP address
[in]portmodule port
[out]net_structnetwork configuration data structure that will contain Compact module network config
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]ipmodule IP address
[in]portmodule port
[out]uart_structUART configuration data structure that will contain Compact module UART config
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]cmd_msgcommunication data structure from which you want to extract datablock
[in]par_typetype of data to be extracted
[in]par_data_cntdata vector number elements to be extracted, otherwise 1
[in]par_data_idxdata vector index (zero based start index); it sets only for vector data type, otherwise 0
[out]par_datait contains the data extracted
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]fppointer files on which to perform printing of the data
[in]cmd_msgcommunication data structure that you want to print
Restituisce
void
uint8_t wiicom_comm_recivIScomplete ( t_wiicom_comm_msg cmd_msg)

function that checks if a command/message has been received completely

Parametri
[in]cmd_msgcommunication data structure on which you want to perform the check
Restituisce
On a complete recived command/message, TRUE is returned, otherwise FALSE is returned
void wiicom_comm_reset ( int8_t  b_reset_all,
t_wiicom_comm_msg cmd_msg 
)

Function that cleans up the data communication structure.

Parametri
[in]b_reset_allif 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_msgcommunication data structure to clean
Restituisce
void
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.

Parametri
[in,out]cmd_msgcommunication data structure to be sent to your Compact, after sending the structure will contain the answer of your Compact
[in]ipmodule IP address to send the command
[in]portModule port to send the command
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in,out]cmd_msgcommunication data structure to be sent to your Compact, after sending the structure will contain the answer of your Compact
[in]socketfda file descriptor for the socket
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]ipmodule IP address
[in]portmodule port
[in]aliasstring that contain the new Compact module alias
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Nota
Psk is save only when security_type is not 0.
Gateway is saved only when nwtype is not 0 (AD-HOC).
Parametri
[in]ipmodule IP address
[in]portmodule port
[in]net_structnetwork configuration data structure that will be set on Compact module
Restituisce
On success, TRUE is returned, On error, FALSE is returned
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.

Parametri
[in]ipmodule IP address
[in]portmodule port
[in]uart_structUART configuration data structure that will be set on Compact module
Restituisce
On success, TRUE is returned, On error, FALSE is returned

Documentazione delle 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.

uint8_t input
uint8_t output
uint8_t prseg
uint8_t sam
uint8_t seg1ph
uint8_t seg2ph
uint8_t sjw
uint32_t speed