Exemple #1
0
static int uart_write(struct bathos_pipe *pipe, const char *buf, int len)
{
    int i;
    for (i = 0; i < len; i++)
        __uart_putc(buf[i]);
    return len;
}
Exemple #2
0
/* -------------------------------------------------------------------------- */
ssize_t
_read_r (struct _reent *reent,
         int           file,
         void          *b,
         size_t        len)
{
    char *buf = (char*) b;

	if (STDIN_FILENO == file)
	{
		
		if (BOARD_HAS_UART)
		{
			/* UART supported. Read from it */


			int  i;
			
			for (i = 0; i < len; i++)
			{
				buf[i] = __uart_getc ();
#ifdef UART_AUTO_ECHO
				__uart_putc (buf[i]);
#endif
				/* Return partial buffer if we get EOL */
				if ('\n' == buf[i])
				{
					return  i;
				}
			}
			
			return  i;			/* Filled the buffer */
		}
		else
		{
			return  0;			/* EOF */
		}
	}
	else
	{
		reent->_errno = EBADF;
		return  -1;
	}
}	/* _read () */