mirror of
https://github.com/espressif/openthread.git
synced 2026-10-19 22:18:17 +00:00
[posix-sim] implement UART flush (#4072)
This commit is contained in:
@@ -224,7 +224,29 @@ void platformUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, fd_set *aE
|
||||
|
||||
otError otPlatUartFlush(void)
|
||||
{
|
||||
return OT_ERROR_NOT_IMPLEMENTED;
|
||||
otError error = OT_ERROR_NONE;
|
||||
ssize_t count;
|
||||
|
||||
otEXPECT_ACTION(s_write_buffer != NULL && s_write_length > 0, error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
while ((count = write(s_out_fd, s_write_buffer, s_write_length)) > 0 && (s_write_length -= count) > 0)
|
||||
{
|
||||
s_write_buffer += count;
|
||||
}
|
||||
|
||||
if (count != -1)
|
||||
{
|
||||
assert(s_write_length == 0);
|
||||
s_write_buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
perror("write(UART)");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void platformUartProcess(void)
|
||||
|
||||
Reference in New Issue
Block a user