Merge pull request #13 from khumarahn/master
teres1-ledctrl: check for more possible errors
This commit is contained in:
commit
eedc61f074
@ -15,6 +15,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
@ -69,17 +71,14 @@ int main (int argc, char **argv)
|
||||
|
||||
device = argv[1];
|
||||
|
||||
if((fd = open(device, O_RDONLY)) == -1)
|
||||
for (;;)
|
||||
{
|
||||
if((fd = open(device, O_RDONLY)) != -1)
|
||||
{
|
||||
perror("Could not open input device");
|
||||
exit(255);
|
||||
}
|
||||
|
||||
export_gpio(LED_NUM);
|
||||
export_gpio(LED_CAPS);
|
||||
|
||||
|
||||
while(read(fd, &ie, sizeof(struct input_event)))
|
||||
while(read(fd, &ie, sizeof(struct input_event)) > 0)
|
||||
{
|
||||
switch (ie.type)
|
||||
{
|
||||
@ -97,6 +96,12 @@ int main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// something went wrong: rinse and repeat
|
||||
close(fd);
|
||||
usleep(65535u);
|
||||
}
|
||||
|
||||
return 0; // never
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user