Hi Christian,

as far as I know it's not in riot directly, but you coult implement it in a couple of lines (simplified -> no error handling...):


char buf[100];
int num_of_bytes = readline_stdin(buf, sizeof(buf));
OR
int num_of_bytes = readline(UART_x, buf, sizeof(buf);

int readline_stdin(char *buf, int size) {
int i = 0;
char c;
do {
    c = getchar();    /** part of stdio.h */
    buf[i++] = c;
} while (c == '\n');
return i;
}

int readline(uart_t uart, char *buf, int size) {
int i = 0;
char c;
do {
    uart_read_blocking(uart, &c);
    buf[i++] = c;
} while (c != '\n');
return i;
}

same for writing...

Cheers,
Hauke


On 24.01.2015 22:11, Christian Mehlis wrote:
hi,

is there any readline /writeline implementation based on the asynchronous periph/uart implementation?

I want to use the uart in a arduino style and I miss an (blocking) interface like:

    char buf[100];
    int buf_size = 100;
    int timeout = 100; //ms
    int num_of_bytes = readline(uart, buf, buf_size, timeout);

also

    int num_of_bytes_written = writeline(uart, line, line_len, timeout);

Best
Christian
_______________________________________________
devel mailing list
devel@riot-os.org
http://lists.riot-os.org/mailman/listinfo/devel

_______________________________________________
devel mailing list
devel@riot-os.org
http://lists.riot-os.org/mailman/listinfo/devel

Reply via email to