From de77f9fb94e52f17bfd5026c4f4614a99044519d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Sat, 18 Oct 2014 20:46:22 +0200 Subject: [PATCH] fix missing gpio warnings --- libguh/hardware/gpio.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libguh/hardware/gpio.cpp b/libguh/hardware/gpio.cpp index d6d9e288..7517ef4c 100644 --- a/libguh/hardware/gpio.cpp +++ b/libguh/hardware/gpio.cpp @@ -62,9 +62,12 @@ bool Gpio::exportGpio() } size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio); - write(fd, buf, len); + if(write(fd, buf, len) != len){ + qDebug() << "ERROR: could not write to gpio"; + close(fd); + return false; + } close(fd); - return true; } @@ -79,9 +82,12 @@ bool Gpio::unexportGpio() return false; } size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio); - write(fd, buf, len); + if(write(fd, buf, len) != len){ + qDebug() << "ERROR: could not write to gpio"; + close(fd); + return false; + } close(fd); - return true; } @@ -127,7 +133,7 @@ bool Gpio::setDirection(int dir) } if(dir == INPUT){ if(write(fd, "in", 3) != 3){ - qDebug() << "ERROR: could not set edge interrupt"; + qDebug() << "ERROR: could not write to gpio"; close(fd); return false; } @@ -137,7 +143,7 @@ bool Gpio::setDirection(int dir) } if(dir == OUTPUT){ if(write(fd, "out", 4) != 4){ - qDebug() << "ERROR: could not set edge interrupt"; + qDebug() << "ERROR: could not write to gpio"; close(fd); return false; } @@ -178,7 +184,7 @@ bool Gpio::setValue(unsigned int value) if(value == LOW){ if(write(fd, "0", 2) != 2){ - qDebug() << "ERROR: could not set edge interrupt"; + qDebug() << "ERROR: could not write to gpio"; close(fd); return false; } @@ -187,7 +193,7 @@ bool Gpio::setValue(unsigned int value) } if(value == HIGH){ if(write(fd, "1", 2) != 2){ - qDebug() << "ERROR: could not set edge interrupt"; + qDebug() << "ERROR: could not write to gpio"; close(fd); return false; }