@@ -928,172 +928,6 @@ int_fast8_t udpardRxSubscriptionReceive(struct UdpardRxSubscription* const self,
928928 const uint_fast8_t redundant_iface_index ,
929929 struct UdpardRxTransfer * const out_transfer );
930930
931- // --------------------------------------------- RPC-SERVICES ---------------------------------------------
932-
933- /// An RPC-service RX port models the interest of the application in receiving RPC-service transfers of
934- /// a particular kind (request or response) and a particular service-ID.
935- struct UdpardRxRPCPort
936- {
937- /// READ-ONLY
938- struct UdpardTreeNode base ;
939-
940- /// READ-ONLY
941- UdpardPortID service_id ;
942-
943- /// See UdpardRxPort.
944- /// Use this to change the transfer-ID timeout value for this RPC-service port.
945- struct UdpardRxPort port ;
946-
947- /// This field can be arbitrarily mutated by the user. It is never accessed by the library.
948- /// Its purpose is to simplify integration with OOP interfaces.
949- void * user_reference ;
950- };
951-
952- /// A service dispatcher is a collection of RPC-service RX ports.
953- /// Anonymous nodes (nodes without a node-ID of their own) cannot use RPC-services.
954- struct UdpardRxRPCDispatcher
955- {
956- /// The local node-ID has to be stored to facilitate correctness checking of incoming transfers.
957- /// This value shall not be modified.
958- /// READ-ONLY
959- UdpardNodeID local_node_id ;
960-
961- /// Refer to UdpardRxMemoryResources.
962- struct UdpardRxMemoryResources memory ;
963-
964- /// READ-ONLY
965- struct UdpardTreeNode * request_ports ;
966- struct UdpardTreeNode * response_ports ;
967- };
968-
969- /// Represents a received Cyphal RPC-service transfer -- either request or response.
970- struct UdpardRxRPCTransfer
971- {
972- struct UdpardRxTransfer base ;
973- UdpardPortID service_id ;
974- bool is_request ;
975- };
976-
977- /// To begin receiving RPC-service requests and/or responses, the application should do this:
978- ///
979- /// 1. Create a new UdpardRxRPCDispatcher instance and initialize it by calling udpardRxRPCDispatcherInit.
980- ///
981- /// 2. Announce its interest in specific RPC-services (requests and/or responses) by calling
982- /// udpardRxRPCDispatcherListen per each. This can be done at any later point as well.
983- ///
984- /// 3. When the local node-ID is known, invoke udpardRxRPCDispatcherStart to inform the library of the
985- /// node-ID value of the local node, and at the same time obtain the address of the UDP/IP multicast group
986- /// to bind the socket(s) to. This step can be taken before or after the RPC-service port registration.
987- /// If the application has to perform a plug-and-play node-ID allocation, it has to complete that beforehand
988- /// (the dispatcher is not needed for PnP node-ID allocation).
989- ///
990- /// 4. Having obtained the UDP/IP endpoint in the previous step, do per redundant network interface:
991- /// - Create a new socket bound to the IP multicast group address and UDP port number obtained earlier.
992- /// The multicast group address depends on the local node-ID.
993- ///
994- /// 5. Read data from the sockets continuously and forward each received UDP datagram to
995- /// udpardRxRPCDispatcherReceive, along with the index of the redundant interface
996- /// the datagram was received on. Only those services that were announced in step 3 will be processed.
997- ///
998- /// The reason the local node-ID has to be specified via a separate call is to allow the application to set up the
999- /// RPC ports early, without having to be aware of its own node-ID. This is useful for applications that perform
1000- /// plug-and-play node-ID allocation. Applications where PnP is not needed will simply call both functions
1001- /// at the same time during early initialization.
1002- ///
1003- /// There is no resource deallocation function ("free") for the RPC dispatcher. This is because the dispatcher
1004- /// does not own any resources. To dispose of a dispatcher safely, the application shall invoke
1005- /// udpardRxRPCDispatcherCancel for each RPC-service port on that dispatcher.
1006- ///
1007- /// The return value is 0 on success.
1008- /// The return value is a negated UDPARD_ERROR_ARGUMENT if any of the input arguments are invalid.
1009- ///
1010- /// The time complexity is constant. This function does not invoke the dynamic memory manager.
1011- int_fast8_t udpardRxRPCDispatcherInit (struct UdpardRxRPCDispatcher * const self ,
1012- const struct UdpardRxMemoryResources memory );
1013-
1014- /// This function must be called exactly once to complete the initialization of the RPC dispatcher.
1015- /// It takes the node-ID of the local node, which is used to derive the UDP/IP multicast group address
1016- /// to bind the sockets to, which is returned via the out parameter.
1017- ///
1018- /// In Cyphal/UDP, each node has a specific IP multicast group address where RPC-service transfers destined to that
1019- /// node are sent to. This is similar to subject (topic) multicast group addressed except that the node-ID takes
1020- /// the place of the subject-ID. The IP multicast group address is derived from the local node-ID.
1021- ///
1022- /// The application is expected to open a separate socket bound to that endpoint per redundant interface,
1023- /// and then feed the UDP datagrams received from these sockets into udpardRxRPCDispatcherReceive,
1024- /// collecting UdpardRxRPCTransfer instances at the output.
1025- ///
1026- /// This function shall not be called more than once per dispatcher. If the local node needs to change its node-ID,
1027- /// this dispatcher instance must be destroyed and a new one created instead.
1028- ///
1029- /// The return value is 0 on success.
1030- /// The return value is a negated UDPARD_ERROR_ARGUMENT if any of the input arguments are invalid.
1031- ///
1032- /// The time complexity is constant. This function does not invoke the dynamic memory manager.
1033- int_fast8_t udpardRxRPCDispatcherStart (struct UdpardRxRPCDispatcher * const self ,
1034- const UdpardNodeID local_node_id ,
1035- struct UdpardUDPIPEndpoint * const out_udp_ip_endpoint );
1036-
1037- /// This function lets the application register its interest in a particular service-ID and kind (request/response)
1038- /// by creating an RPC-service RX port. The port pointer shall retain validity until its unregistration or until
1039- /// the dispatcher is destroyed. The service instance shall not be moved or destroyed.
1040- ///
1041- /// If such registration already exists, it will be unregistered first as if udpardRxRPCDispatcherCancel was
1042- /// invoked by the application, and then re-created anew with the new parameters.
1043- ///
1044- /// For the meaning of extent, please refer to the documentation of the subscription pipeline.
1045- ///
1046- /// By default, the transfer-ID timeout value is set to UDPARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC.
1047- /// It can be changed by the user at any time by modifying the corresponding field in the registration instance.
1048- ///
1049- /// The return value is 1 if a new registration has been created as requested.
1050- /// The return value is 0 if such registration existed at the time the function was invoked. In this case,
1051- /// the existing registration is terminated and then a new one is created in its place. Pending transfers may be lost.
1052- /// The return value is a negated UDPARD_ERROR_ARGUMENT if any of the input arguments are invalid.
1053- ///
1054- /// The time complexity is logarithmic from the number of current registrations under the specified transfer kind
1055- /// (request or response).
1056- /// This function does not allocate new memory. The function may deallocate memory if such registration already
1057- /// existed; the deallocation behavior is specified in the documentation for udpardRxRPCDispatcherCancel.
1058- int_fast8_t udpardRxRPCDispatcherListen (struct UdpardRxRPCDispatcher * const self ,
1059- struct UdpardRxRPCPort * const port ,
1060- const UdpardPortID service_id ,
1061- const bool is_request ,
1062- const size_t extent );
1063-
1064- /// This function reverses the effect of udpardRxRPCDispatcherListen.
1065- /// If the registration is found, all its memory is de-allocated (session states and payload buffers).
1066- /// Please refer to the UdpardRxPort session description for detailed information on the amount of memory freed.
1067- ///
1068- /// The return value is 1 if such registration existed (and, therefore, it was removed).
1069- /// The return value is 0 if such registration does not exist. In this case, the function has no effect.
1070- /// The return value is a negated UDPARD_ERROR_ARGUMENT if any of the input arguments are invalid.
1071- ///
1072- /// The time complexity is logarithmic from the number of current registration under the specified transfer kind.
1073- /// This function does not allocate new memory.
1074- int_fast8_t udpardRxRPCDispatcherCancel (struct UdpardRxRPCDispatcher * const self ,
1075- const UdpardPortID service_id ,
1076- const bool is_request );
1077-
1078- /// Datagrams received from the sockets of this RPC service dispatcher are fed into this function.
1079- /// It is the analog of udpardRxSubscriptionReceive for RPC-service transfers.
1080- /// Please refer to the documentation of udpardRxSubscriptionReceive for the usage information.
1081- ///
1082- /// Frames (datagrams) that belong to transfers for which there is no active RX RPC port are ignored.
1083- ///
1084- /// The "out_port" pointer-to-pointer can be used to retrieve the specific UdpardRxRPCPort instance that was used to
1085- /// process the received transfer. Remember that each UdpardRxRPCPort instance has a user reference field,
1086- /// which in combination with this feature can be used to construct OOP interfaces on top of the library.
1087- /// If this is not needed, the pointer-to-pointer can be NULL.
1088- ///
1089- /// The memory pointed to by out_transfer may be mutated arbitrarily if no transfer is completed.
1090- int_fast8_t udpardRxRPCDispatcherReceive (struct UdpardRxRPCDispatcher * const self ,
1091- const UdpardMicrosecond timestamp_usec ,
1092- const struct UdpardMutablePayload datagram_payload ,
1093- const uint_fast8_t redundant_iface_index ,
1094- struct UdpardRxRPCPort * * const out_port ,
1095- struct UdpardRxRPCTransfer * const out_transfer );
1096-
1097931// =====================================================================================================================
1098932// ==================================================== MISC =====================================================
1099933// =====================================================================================================================
0 commit comments