Update: DISCONNECT (Issue #31) and others

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2016-10-03 11:17:35 +09:00
parent 76f58a60a3
commit 93df7db12e
22 changed files with 192 additions and 150 deletions

View File

@@ -180,24 +180,30 @@ void LightIndicator::init()
pinMode(LIGHT_INDICATOR_BLUE);
}
void LightIndicator::lit(int gpioNo, const char* onoff)
int LightIndicator::lit(int gpioNo, const char* onoff)
{
int rc = 0;
if( _gpio[gpioNo] )
{
write(_gpio[gpioNo], onoff, 1);
rc = write(_gpio[gpioNo], onoff, 1);
}
return rc;
}
void LightIndicator::pinMode(int gpioNo)
{
int fd = open("/sys/class/gpio/export", O_WRONLY);
int rc = 0;
int fd = rc; // eliminate unused warnning of compiler
fd = open("/sys/class/gpio/export", O_WRONLY);
if ( fd < 0 )
{
return;
}
char no[4];
sprintf(no,"%d", gpioNo);
write(fd, no, strlen(no));
rc = write(fd, no, strlen(no));
close(fd);
char fileName[64];
@@ -208,9 +214,8 @@ void LightIndicator::pinMode(int gpioNo)
{
return;
}
write(fd,"out", 3);
rc = write(fd,"out", 3);
close(fd);
sprintf( fileName, "/sys/class/gpio/gpio%d/value", gpioNo);
fd = open(fileName, O_WRONLY);
if ( fd > 0 )