Updated function descriptions in headers

Change-Id: I8a8112744881f5141acbb0e13492c82578c4de91
This commit is contained in:
Andrey Perminov 2020-05-06 13:05:28 -07:00
parent 6bdc768fbc
commit 66be660f6d
2 changed files with 90 additions and 21 deletions

View File

@ -38,25 +38,94 @@ typedef struct {
} HCP_comm_t;
/**
* @brief Helper function for receiving HCP commands
* @brief Send prepared command packet to FPC BM-LIte
*
* @param[in] hcp_comm - pointer to HCP_comm struct
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_send(HCP_comm_t *hcp_comm);
* @param command_id command to send
* @param arg_key1 first key to receive
* @param arg_data1 first argument data
* @param arg_data1_length first argument data length
* @param arg_key2 second key to receive
* @param arg_data2 second argument data
* @param arg_data2_length second argument
/**
* @brief Receive answer from FPC BM-LIte
*
* @param[in] hcp_comm - pointer to HCP_comm struct
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_receive(HCP_comm_t *hcp_comm);
fpc_bep_result_t bmlite_send(HCP_comm_t *hcp_comm);
/**
* @brief Send prepared command packet to FPC BM-LIte and receive answer
*
* @param[in] hcp_comm - pointer to HCP_comm struct
*
* Returns result of executing command in BM-LIte in hcp_comm->bep_result
* if communication with BM-Lite was successful.
* Please not that some BM-Lite command does not return result in ARG_RESULT.
* They return data with some other argument instead.
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_tranceive(HCP_comm_t *hcp_comm);
/**
* @brief Initialize new command for BM-Lite
*
* @param[in] hcp_comm - pointer to HCP_comm struct
* @param[in] cmd - command to send
* @param[in] arg - Argument for the command without parameterd
* Use ARG_NONE and add arguments by bmlite_add_arg() if
* you need to add argument with parameter
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_init_cmd(HCP_comm_t *hcp_comm, uint16_t cmd, uint16_t arg);
fpc_bep_result_t bmlite_add_arg(HCP_comm_t *hcp_comm, uint16_t arg, void *data, uint16_t size);
/**
* @brief Add argument to command.
* Must be used only after command buffer is initialized by bmlite_init_cmd()
*
* @param[in] hcp_comm - pointer to HCP_comm struct
* @param[in] arg_type - argument key
* @param[in] arg_data - argument data
* @param[in] arg_size - argument data length
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_add_arg(HCP_comm_t *hcp_comm, uint16_t arg_type, void *arg_data, uint16_t arg_size);
/**
* @brief Search for argument in received answer.
*
* @param[in] hcp_comm - pointer to HCP_comm struct
* @param[in] arg_type - argument key
*
* If found, place pointer to argument data in receiving buffer to hcp_comm->arg.data
* and size of the argument in hcp_comm->arg.size
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_get_arg(HCP_comm_t *hcp_comm, uint16_t arg_type);
fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_length);
/**
* @brief Search for argument in received answer and copyargument's data
* to
*
* @param[in] hcp_comm - pointer to HCP_comm struct
* @param[in] arg_type - argument key
* @param[out] arg_data - pointer for memory to copy argument value
* @param[out] arg_data_size - size of data area for copying argument value
*
* If found, argument's data will be copyed to arg_data
* If received argument's size greater that arg_data_size, the copyed data will be
* truncated to arg_data_size.
* Still hcp_comm->arg.data will be pointed to argument's data in receiving buffer
* and real size of the argument will be hcp_comm->arg.size
*
* @return ::fpc_bep_result_t
*/
fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_size);

View File

@ -61,21 +61,21 @@ fpc_bep_result_t bmlite_init_cmd(HCP_comm_t *hcp_comm, uint16_t cmd, uint16_t ar
return FPC_BEP_RESULT_OK;
}
fpc_bep_result_t bmlite_add_arg(HCP_comm_t *hcp_comm, uint16_t arg, void *data, uint16_t size)
fpc_bep_result_t bmlite_add_arg(HCP_comm_t *hcp_comm, uint16_t arg_type, void *arg_data, uint16_t arg_size)
{
if(hcp_comm->pkt_size + 4 + size > hcp_comm->pkt_size_max) {
if(hcp_comm->pkt_size + 4 + arg_size > hcp_comm->pkt_size_max) {
bmlite_on_error(BMLITE_ERROR_SEND_CMD, FPC_BEP_RESULT_NO_MEMORY);
return FPC_BEP_RESULT_NO_MEMORY;
}
((_HCP_cmd_t *)hcp_comm->pkt_buffer)->args_nr++;
_CMD_arg_t *args = (_CMD_arg_t *)(&hcp_comm->pkt_buffer[hcp_comm->pkt_size]);
args->arg = arg;
args->size = size;
if(size) {
memcpy(&args->pld, data, size);
args->arg = arg_type;
args->size = arg_size;
if(arg_size) {
memcpy(&args->pld, arg_data, arg_size);
}
hcp_comm->pkt_size += 4 + size;
hcp_comm->pkt_size += 4 + arg_size;
return FPC_BEP_RESULT_OK;
}
@ -104,7 +104,7 @@ fpc_bep_result_t bmlite_get_arg(HCP_comm_t *hcp_comm, uint16_t arg_type)
return FPC_BEP_RESULT_INVALID_ARGUMENT;
}
fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_length)
fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *arg_data, uint16_t arg_data_size)
{
fpc_bep_result_t bep_result;
bep_result = bmlite_get_arg(hcp_comm, arg_key);
@ -113,7 +113,7 @@ fpc_bep_result_t bmlite_copy_arg(HCP_comm_t *hcp_comm, uint16_t arg_key, void *a
bmlite_on_error(BMLITE_ERROR_GET_ARG, FPC_BEP_RESULT_NO_MEMORY);
return FPC_BEP_RESULT_NO_MEMORY;
}
memcpy(arg_data, hcp_comm->arg.data, HCP_MIN(arg_data_length, hcp_comm->arg.size));
memcpy(arg_data, hcp_comm->arg.data, HCP_MIN(arg_data_size, hcp_comm->arg.size));
} else {
bmlite_on_error(BMLITE_ERROR_GET_ARG, FPC_BEP_RESULT_INVALID_ARGUMENT);
return FPC_BEP_RESULT_INVALID_ARGUMENT;