diff options
author | Lasse Dalegaard <dalegaard@gmail.com> | 2021-02-27 10:56:14 +0000 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2021-03-01 13:46:59 -0500 |
commit | f8b0ea53dcf2a04ca847aa6cbf4683eed98a3321 (patch) | |
tree | 0c4e73958fa9c078866c7e13896788edc7cb7a3f /klippy/chelper/serialqueue.c | |
parent | 70a1b752c9930beb5bdc7f7c07f8cc9b94333c56 (diff) | |
download | kutter-f8b0ea53dcf2a04ca847aa6cbf4683eed98a3321.tar.gz kutter-f8b0ea53dcf2a04ca847aa6cbf4683eed98a3321.tar.xz kutter-f8b0ea53dcf2a04ca847aa6cbf4683eed98a3321.zip |
serialqueue: correctly report EOF errors
If `klippy` loses connection to a device, the next `read()` from the
device file descriptor will result in a zero-byte result, i.e. an `EOF`.
Right now this gives a confusing error message, so this simply handles
the special case of `EOF` and outputs a better log message.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Diffstat (limited to 'klippy/chelper/serialqueue.c')
-rw-r--r-- | klippy/chelper/serialqueue.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/klippy/chelper/serialqueue.c b/klippy/chelper/serialqueue.c index f9cfd148..3684a721 100644 --- a/klippy/chelper/serialqueue.c +++ b/klippy/chelper/serialqueue.c @@ -573,7 +573,10 @@ input_event(struct serialqueue *sq, double eventtime) int ret = read(sq->serial_fd, &sq->input_buf[sq->input_pos] , sizeof(sq->input_buf) - sq->input_pos); if (ret <= 0) { - report_errno("read", ret); + if(ret < 0) + report_errno("read", ret); + else + errorf("Got EOF when reading from device"); pollreactor_do_exit(&sq->pr); return; } |