|
|
@ -431,8 +431,13 @@ uint32_t ureg_get_num_units(void) |
|
|
|
return (uint32_t) unit_count; |
|
|
|
return (uint32_t) unit_count; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern osMutexId mutScratchBufferHandle; |
|
|
|
|
|
|
|
|
|
|
|
/** Deliver message to it's destination unit */ |
|
|
|
/** Deliver message to it's destination unit */ |
|
|
|
void ureg_deliver_unit_request(TF_Msg *msg) |
|
|
|
void ureg_deliver_unit_request(TF_Msg *msg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// we must claim the scratch buffer because it's used by many units internally
|
|
|
|
|
|
|
|
assert_param(osOK == osMutexWait(mutScratchBufferHandle, 5000)); |
|
|
|
{ |
|
|
|
{ |
|
|
|
PayloadParser pp = pp_start(msg->data, msg->len, NULL); |
|
|
|
PayloadParser pp = pp_start(msg->data, msg->len, NULL); |
|
|
|
uint8_t callsign = pp_u8(&pp); |
|
|
|
uint8_t callsign = pp_u8(&pp); |
|
|
@ -444,7 +449,7 @@ void ureg_deliver_unit_request(TF_Msg *msg) |
|
|
|
|
|
|
|
|
|
|
|
if (callsign == 0 || !pp.ok) { |
|
|
|
if (callsign == 0 || !pp.ok) { |
|
|
|
com_respond_error(msg->frame_id, E_MALFORMED_COMMAND); |
|
|
|
com_respond_error(msg->frame_id, E_MALFORMED_COMMAND); |
|
|
|
return; |
|
|
|
goto quit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UlistEntry *li = ulist_head; |
|
|
|
UlistEntry *li = ulist_head; |
|
|
@ -457,10 +462,11 @@ void ureg_deliver_unit_request(TF_Msg *msg) |
|
|
|
// error is expected to have already been reported.
|
|
|
|
// error is expected to have already been reported.
|
|
|
|
if (rv == E_SUCCESS) { |
|
|
|
if (rv == E_SUCCESS) { |
|
|
|
if (confirmed) com_respond_ok(msg->frame_id); |
|
|
|
if (confirmed) com_respond_ok(msg->frame_id); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
com_respond_error(msg->frame_id, rv); |
|
|
|
com_respond_error(msg->frame_id, rv); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
goto quit; |
|
|
|
} |
|
|
|
} |
|
|
|
li = li->next; |
|
|
|
li = li->next; |
|
|
|
} |
|
|
|
} |
|
|
@ -468,6 +474,9 @@ void ureg_deliver_unit_request(TF_Msg *msg) |
|
|
|
// Not found
|
|
|
|
// Not found
|
|
|
|
com_respond_error(msg->frame_id, E_NO_SUCH_UNIT); |
|
|
|
com_respond_error(msg->frame_id, E_NO_SUCH_UNIT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
quit: |
|
|
|
|
|
|
|
assert_param(osOK == osMutexRelease(mutScratchBufferHandle)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Send a response for a unit-list request */ |
|
|
|
/** Send a response for a unit-list request */ |
|
|
|
void ureg_report_active_units(TF_ID frame_id) |
|
|
|
void ureg_report_active_units(TF_ID frame_id) |
|
|
|