mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
improve uart0_puts
This commit is contained in:
parent
ca6f20f384
commit
141bec6427
@ -20,13 +20,26 @@ fd_set _native_uart_rfds;
|
|||||||
|
|
||||||
inline int uart0_puts(char *astring, int length)
|
inline int uart0_puts(char *astring, int length)
|
||||||
{
|
{
|
||||||
|
int nwritten, offset;
|
||||||
|
|
||||||
|
nwritten = 0;
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
_native_in_syscall = 1;
|
_native_in_syscall = 1;
|
||||||
/* XXX: handle short writes: */
|
|
||||||
if (write(_native_uart_out, astring, length) == -1) {
|
while ((length > 0) &&(nwritten = write(_native_uart_out, astring+offset, length-offset)) > 0) {
|
||||||
err(EXIT_FAILURE, "uart0_puts: write");
|
offset += nwritten;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
if (nwritten == -1) {
|
||||||
|
err(EXIT_FAILURE, "uart0_puts: write");
|
||||||
|
}
|
||||||
|
else if ((length > 0) && (nwritten == 0)) {
|
||||||
|
/* XXX: handle properly */
|
||||||
|
errx(EXIT_FAILURE, "uart0_puts: Could not write to stdout. I don't know what to do now.");
|
||||||
|
}
|
||||||
|
|
||||||
_native_in_syscall = 0;
|
_native_in_syscall = 0;
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user