Mercurial > ublox > ublox8
changeset 50:d293465f3ced
dump-ubx: switch to file-descriptor based I/O
Buffering doesn't really help with anything here. It only adds latency.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 16 Jan 2020 16:31:29 -0500 |
parents | cf39d3a8140b |
children | b668806db3fc |
files | dump-ubx.c |
diffstat | 1 files changed, 8 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/dump-ubx.c Thu Jan 16 16:39:15 2020 -0500 +++ b/dump-ubx.c Thu Jan 16 16:31:29 2020 -0500 @@ -21,7 +21,8 @@ */ #include "dump-common.h" -#include "xstdio.h" + +#include <jeffpc/io.h> void process_ubx_message(const struct ubx_header *header, const uint8_t *raw, size_t len, @@ -29,15 +30,15 @@ { int ret; - ret = xfwrite(stdout, header, sizeof(*header)); + ret = xwrite(STDOUT_FILENO, header, sizeof(*header)); if (ret) { - fprintf(stderr, "Error: Failed to write out UBX header\n"); + fprintf(stderr, "Error: Failed to write out UBX header: %s\n", + xstrerror(ret)); return; } - ret = xfwrite(stdout, raw, len + 2); /* +2 for the checksum */ + ret = xwrite(STDOUT_FILENO, raw, len + 2); /* +2 for the checksum */ if (ret) - fprintf(stderr, "Error: Failed to write out UBX data\n"); - - fflush(stdout); + fprintf(stderr, "Error: Failed to write out UBX data: %s\n", + xstrerror(ret)); }