I am a bit stuck in understanding a proper way of using the services.
So if I am correct, I need both publisher and subscriber to perform the service call as there is no callback in v1.0.
At the beginning, I assume we would need a subscriber:
(void) canardRxSubscribe(&ins, // Subscribe to an arbitrary service response.
CanardTransferKindResponse,
123, // The Service-ID to subscribe to.
1024, // The maximum payload size (max DSDL object size).
CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC,
&my_service_subscription);
Then, if I want to call a service, I just need to create a transfer object and push it (publish):
const CanardTransfer transfer = {
.timestamp_usec = transmission_deadline, // Zero if transmission deadline is not limited.
.priority = CanardPriorityNominal,
.transfer_kind = CanardTransferKindMessage,
.port_id = 123, // This is the service-ID.
.remote_node_id = CANARD_NODE_ID_UNSET,
.transfer_id = my_message_transfer_id,
.payload_size = 47,
.payload = "\x2D\x00" "Sancho, it strikes me thou art in great fear.",
};
int32_t result = canardTxPush(&ins, &transfer);
This will send a message to the remote_id, the remote_id will read the service id and transfer id and do some tasks and send back the payload.
And after publishing this, I would then need to accept a frame:
CanardTransfer transfer;
const int8_t result = canardRxAccept(&ins,
&received_frame, // The CAN frame received from the bus.
redundant_interface_index, // If the transport is not redundant, use 0.
&transfer);
Is that a correct flow? I got this understanding from reading the header file