YGQ
(William Yang)
April 16, 2019, 6:03am
1
How should these two parameters be understood?
Sorry that your question was looked over! These are pointers to callback handlers. on_reception
is invoked when a new transfer is received (and validated for data integrity) by libcanard. should_accept
is invoked when libcanard receives a new transfer and it needs to understand if the transfer is of interest to the application. This is actually explained in the docs:
/**
* The application must implement this function and supply a pointer to it to the library during initialization.
* The library calls this function to determine whether the transfer should be received.
*
* If the application returns true, the value pointed to by 'out_data_type_signature' must be initialized with the
* correct data type signature, otherwise transfer reception will fail with CRC mismatch error. Please refer to the
* specification for more details about data type signatures. Signature for any data type can be obtained in many
* ways; for example, using the command line tool distributed with Libcanard (see the repository).
*/
typedef bool (* CanardShouldAcceptTransfer)(const CanardInstance* ins, ///< Library instance
uint64_t* out_data_type_signature, ///< Must be set by the application!
uint16_t data_type_id, ///< Refer to the specification
CanardTransferType transfer_type, ///< Refer to CanardTransferType
uint8_t source_node_id); ///< Source node ID or Broadcast (0)
/**
* This function will be invoked by the library every time a transfer is successfully received.
* If the application needs to send another transfer from this callback, it is highly recommended
* to call canardReleaseRxTransferPayload() first, so that the memory that was used for the block
* buffer can be released and re-used by the TX queue.
This file has been truncated. show original