protocol_splitter: return 0 when no data to read instead of -1

This avoids mavlink adding another usleep() due to read error
This commit is contained in:
Beat Küng 2021-08-13 14:08:33 +02:00 committed by Daniel Agar
parent 375b014444
commit 868f9cebb0
1 changed files with 4 additions and 4 deletions

View File

@ -366,7 +366,7 @@ pollevent_t DevCommon::poll_state(struct file *filp)
int DevCommon::try_to_copy_data(char *buffer, size_t buflen, MessageType message_type)
{
if (buflen == 0) {
return -1;
return 0;
}
switch (message_type) {
@ -398,7 +398,7 @@ int DevCommon::try_to_copy_data(char *buffer, size_t buflen, MessageType message
return len_to_copy;
} else {
return -1;
return 0;
}
case MessageType::Rtps:
@ -429,14 +429,14 @@ int DevCommon::try_to_copy_data(char *buffer, size_t buflen, MessageType message
return len_to_copy;
} else {
return -1;
return 0;
}
break;
default:
return -1;
return 0;
}
}