fixed gpio warnings (errors on trusty and utopic)

This commit is contained in:
Simon Stürz 2014-10-29 13:37:50 +01:00 committed by Michael Zanetti
parent de77f9fb94
commit f62e7d9e01

View File

@ -61,9 +61,9 @@ bool Gpio::exportGpio()
return false; return false;
} }
size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio); uint len = snprintf(buf, sizeof(buf), "%d", m_gpio);
if(write(fd, buf, len) != len){ if(write(fd, buf, len) != len){
qDebug() << "ERROR: could not write to gpio"; qDebug() << "ERROR: could not set edge interrupt";
close(fd); close(fd);
return false; return false;
} }
@ -81,9 +81,10 @@ bool Gpio::unexportGpio()
//qDebug() << "ERROR: could not open /sys/class/gpio/unexport"; //qDebug() << "ERROR: could not open /sys/class/gpio/unexport";
return false; return false;
} }
size_t len = snprintf(buf, sizeof(buf), "%d", m_gpio);
uint len = snprintf(buf, sizeof(buf), "%d", m_gpio);
if(write(fd, buf, len) != len){ if(write(fd, buf, len) != len){
qDebug() << "ERROR: could not write to gpio"; qDebug() << "ERROR: could not set edge interrupt";
close(fd); close(fd);
return false; return false;
} }
@ -235,7 +236,11 @@ int Gpio::getValue()
} }
char ch; char ch;
int value = -1; int value = -1;
read(fd, &ch, 1); ssize_t len = read(fd, &ch, 1);
if(len != 1){
close(fd);
return -1;
}
if (ch != '0') { if (ch != '0') {
value = 1; value = 1;