pdcomm_gem_equipment_respond_command
Function
Sends the S2F42 Host Command Acknowledge for a received S2F41.
PdcommStatus pdcomm_gem_equipment_respond_command(PdcommTcpEndpoint *endpoint, PdcommGemResult *result, uint8_t decision, const PdcommGemCommandIssue *issues, size_t count, PdcommGemCommandReply *reply)The validation and the completion metadata were frozen when the request arrived, even if the control state changes later:
- When validation rejected the request, its original HCACK and CPACK entries are sent;
decisionmust still be 0 to 6, andissuesandcountare ignored. - When validation accepted the request,
decisionis sent as the HCACK. Only decision #PDCOMM_GEM_COMMAND_PARAMETER_ERRORS may carry issues (codes 1 to 3); it may also carry none. The original command limits (max_errors,max_identifier_bytes) apply.
The whole response is prepared before it is sent. Only a successful send sets responded, reply_sent, and the actual acknowledgement in the result. After a failure reply is cleared and the result stays retryable: retry the same decision and never re-execute completed work. Start deferred work only after an HCACK 4 response was accepted. The completion CEID is returned only for an actual HCACK 0 or 4; report the event separately with pdcomm_gem_equipment_publish_event(). The original TCP event may already be destroyed.
Parameters
| Name | Description |
|---|---|
endpoint | The Equipment endpoint that produced result. |
result | Request result with outcome #PDCOMM_GEM_COMMAND_RECEIVED. |
decision | HCACK to send for an accepted request, one of the PDCOMM_GEM_COMMAND_* values 0 to 6. |
issues | Array of count CPACK entries for decision 3. May be NULL when count is 0. |
count | Number of entries; must be 0 unless decision is 3. |
reply | Caller storage; set reply->struct_size before the call. Cleared first and written on success. |
Returns
#PDCOMM_OK when S2F42 was queued; #PDCOMM_INVALID_ARGUMENT when endpoint, result, or reply is NULL, reply->struct_size is too small, decision is above 6, result is not a remote command result, issues are supplied for a decision other than 3, an issue name is NULL or invalid, or an issue code is outside 1 to 3; #PDCOMM_LIMIT_EXCEEDED when count exceeds max_errors, an issue name exceeds max_identifier_bytes, or the message exceeds the item limits; #PDCOMM_INVALID_STATE when result is a Host reply, the endpoint has no GEM Equipment, or communication is not COMMUNICATING; #PDCOMM_STALE_TOKEN when the request came from another endpoint, an older connection generation or selection, was already answered, or its reply slot is no longer open; #PDCOMM_BACKPRESSURE when a TCP event is staged or the TCP queue is full; #PDCOMM_ALLOCATION_FAILED; #PDCOMM_POISONED when the endpoint is poisoned or a panic was contained; or another TCP reply status, as for pdcomm_tcp_reply().
Notes
- Thread safety: this call mutates
result. Do not run it concurrently with getters on the same result or with pdcomm_gem_result_destroy().