From a4c63bea6bcc025ba76c736e2f934bb238286a7c Mon Sep 17 00:00:00 2001 From: Bianka Forkel <noreply@fortiss.org> Date: Tue, 27 Jun 2017 09:29:10 +0000 Subject: [PATCH] Laser range finder: error value -1 refs 7886 --- .../trunk/lib/src/LaserRangeFinder.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c index c440bf94..2790bc86 100644 --- a/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c +++ b/org.fortiss.af3.platform.raspberry/trunk/lib/src/LaserRangeFinder.c @@ -28,6 +28,13 @@ GEN_TYPE_boolean lrf_is_noval() { /** Get one distance measurement from the laser range finder. */ GEN_TYPE_int lrf_read() { + + if (uart_filestream == -1) + return -1; + + // free buffer + uart_flush(); + char bytes[5]; int n_read = 0; @@ -38,9 +45,6 @@ GEN_TYPE_int lrf_read() { int d; - // free buffer - uart_flush(); - // looks like a blocking call and actually is but is always very fast // since it only has to read the queue while (1) { -- GitLab