Dedicated error code for transfers of excessive length

This commit is contained in:
Pavel Kirienko
2015-04-30 12:04:55 +03:00
parent 0ea4e5e4e0
commit 5c0314e187
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -33,6 +33,7 @@ const int16_t ErrNotInited = 8;
const int16_t ErrRecursiveCall = 9;
const int16_t ErrLogic = 10;
const int16_t ErrPassiveMode = 11; ///< Operation not permitted in passive mode
const int16_t ErrTransferTooLong = 12; ///< Transfer of this length cannot be sent with given transfer type
/**
* @}
*/
@@ -21,8 +21,7 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
{
if (payload_len > getMaxPayloadLenForTransferType(transfer_type))
{
UAVCAN_ASSERT(0);
return -ErrInvalidParam;
return -ErrTransferTooLong;
}
Frame frame(data_type_.getID(), transfer_type, dispatcher_.getNodeID(), dst_node_id, 0, tid);
@@ -129,6 +128,12 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
int TransferSender::send(const uint8_t* payload, unsigned payload_len, MonotonicTime tx_deadline,
MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id)
{
// This check must be performed before TID is incremented to avoid skipping TID values on failures
if (payload_len > getMaxPayloadLenForTransferType(transfer_type))
{
return -ErrTransferTooLong;
}
const OutgoingTransferRegistryKey otr_key(data_type_.getID(), transfer_type, dst_node_id);
UAVCAN_ASSERT(!tx_deadline.isZero());