canardv0 nxstyle fix

This commit is contained in:
Peter van der Perk 2022-08-01 17:46:45 +02:00 committed by Xiang Xiao
parent 819c34e975
commit c026bd824a

View File

@ -56,14 +56,14 @@
* Pre-processor Definitions
****************************************************************************/
/* Application constants */
/* Application constants */
#define APP_VERSION_MAJOR 1
#define APP_VERSION_MINOR 0
#define APP_NODE_NAME CONFIG_EXAMPLES_LIBCANARDV0_APP_NODE_NAME
#define GIT_HASH 0xb28bf6ac
/* Some useful constants defined by the UAVCAN specification.
/* Some useful constants defined by the UAVCAN specification.
* Data type signature values can be easily obtained with the script
* show_data_type_info.py
*/
@ -99,7 +99,8 @@ static CanardInstance canard;
/* Arena for memory allocation, used by the library */
static uint8_t canard_memory_pool[CONFIG_EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE];
static uint8_t canard_memory_pool
[CONFIG_EXAMPLES_LIBCANARDV0_NODE_MEM_POOL_SIZE];
static uint8_t unique_id[UNIQUE_ID_LENGTH_BYTES] =
{ 0x00, 0x00, 0x00, 0x00,
@ -203,13 +204,17 @@ static void onTransferReceived(CanardInstance *ins,
*/
/* Image CRC skipped */
/* HardwareVersion */
/* Major skipped */
/* Minor skipped */
memcpy(&buffer[24], unique_id, UNIQUE_ID_LENGTH_BYTES);
/* Certificate of authenticity skipped */
/* Name */
const size_t name_len = strlen(APP_NODE_NAME);
@ -268,7 +273,8 @@ static bool shouldAcceptTransfer(const CanardInstance * ins,
if ((transfer_type == CanardTransferTypeRequest) &&
(data_type_id == UAVCAN_GET_NODE_INFO_DATA_TYPE_ID))
{
*out_data_type_signature = UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE;
*out_data_type_signature =
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE;
return true;
}
}
@ -301,8 +307,8 @@ void process1HzTasks(uint64_t timestamp_usec)
100U * stats.peak_usage_blocks / stats.capacity_blocks;
#ifdef CONFIG_DEBUG_CAN
printf
("Memory pool stats: capacity %u blocks, usage %u blocks, peak usage %u blocks (%u%%)\n",
printf("Memory pool stats: capacity %u blocks, usage %u blocks,"
" peak usage %u blocks (%u%%)\n",
stats.capacity_blocks, stats.current_usage_blocks,
stats.peak_usage_blocks, peak_percent);
#endif
@ -345,7 +351,8 @@ void process1HzTasks(uint64_t timestamp_usec)
const int resp_res =
canardRequestOrRespond(&canard, dest_id,
UAVCAN_GET_NODE_INFO_DATA_TYPE_SIGNATURE,
UAVCAN_GET_NODE_INFO_DATA_TYPE_ID, &transfer_id,
UAVCAN_GET_NODE_INFO_DATA_TYPE_ID,
&transfer_id,
CANARD_TRANSFER_PRIORITY_LOW, CanardRequest,
payload, 0);
if (resp_res <= 0)
@ -372,7 +379,7 @@ void processTxRxOnce(CanardNuttXInstance * nuttxcan, int timeout_msec)
/* Transmitting */
for (txf = NULL; (txf = canardPeekTxQueue(&canard)) != NULL;)
for (txf = NULL; (txf = canardPeekTxQueue(&canard)) != NULL; )
{
const int tx_res = canardNuttXTransmit(nuttxcan, txf, 0);
if (tx_res < 0) /* Failure - drop the frame and report */
@ -471,13 +478,14 @@ static int canard_daemon(int argc, char *argv[])
onTransferReceived, shouldAcceptTransfer, (void *)(12345));
canardSetLocalNodeID(&canard, CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID);
printf("canard_daemon: canard initialized\n");
printf("start node (ID: %d Name: %s)\n", CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID,
printf("start node (ID: %d Name: %s)\n",
CONFIG_EXAMPLES_LIBCANARDV0_NODE_ID,
APP_NODE_NAME);
g_canard_daemon_started = true;
uint64_t next_1hz_service_at = getMonotonicTimestampUSec();
for (;;)
for (; ; )
{
processTxRxOnce(&canardnuttx_instance, 10);
@ -517,7 +525,8 @@ int main(int argc, FAR char *argv[])
return EXIT_SUCCESS;
}
ret = task_create("canard_daemon", CONFIG_EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY,
ret = task_create("canard_daemon",
CONFIG_EXAMPLES_LIBCANARDV0_DAEMON_PRIORITY,
CONFIG_EXAMPLES_LIBCANARDV0_STACKSIZE, canard_daemon,
NULL);
if (ret < 0)