rs

FTDI serial communication program
git clone git://git.2f30.org/rs
Log | Files | Refs | README | LICENSE

commit 4354099cb16c39ed251114cdfe71ad16a5a4ad72
parent 425e572b433f96a53a851d26aee2885081b2e030
Author: sin <sin@2f30.org>
Date:   Thu, 12 Dec 2013 11:44:50 +0000

Error out on ftdi_write_data() failures

Diffstat:
Mrs.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/rs.c b/rs.c @@ -67,8 +67,14 @@ loop(void) n = read(STDIN_FILENO, buf, sizeof(buf)); if (n < 0 && errno == EINTR) continue; - if (n > 0) - ftdi_write_data(&ftdictx, buf, n); + if (n > 0) { + n = ftdi_write_data(&ftdictx, buf, n); + if (n < 0) { + ttyrestore(); + enprintf(EXIT_FAILURE, "ftdi_write_data: write error: %s\n", + ftdi_get_error_string(&ftdictx)); + } + } n = ftdi_read_data(&ftdictx, buf, sizeof(buf)); if (n < 0) { ttyrestore();