Hi,
I wrote a small program to check if a button is pressed:
Code:
* ----- Small test program to check which button is pressed ---------
* Prints a string (2 characters) to stdout:
* FF: No key pressed
* 00: Connect (IDS)
* 01: Button avove page bar
* 02: Top left button
* 03: NEWS
* 04: BOOKS
* 05: DOCS
* 06: NOTES
* 07: page bar left
* 08: page bar right
* 09: UP arrow
* 0A: DOT (enter)
* 0B: DOWN arrow
* 0E: Power on button
* E0: Error, cannot open device
* E1: Error, cannot get button state
*/
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define BUTTON_IOCTL_BASE 'b'
#define BUTTON_IOCTL_GET_STATUS _IOR( BUTTON_IOCTL_BASE,7,unsigned int)
int main(int argc, char *argv[]) {
int i;
int status;
int dev;
if ((dev = open("/dev/buttons", O_RDWR)) < 0) {
fprintf(stderr,"ERROR opening failed\n");
status = 0xe0;
}
else if (ioctl(dev, BUTTON_IOCTL_GET_STATUS, &status)) {
fprintf(stderr, "ERROR: BUTTON_IOCTL_GET_STATUS failed\n");
status = 0xe2;
}
printf("%02X", status & 0xff);
return 0;
}
It can be compiled as follows (with de development kit installed and running setup_build_env.sh)
Code:
arm-linux-gcc checkbutton.c -o checkbutton
It works like a charm (when I run it on the iliad via ssh),
except when I run it from the startup scripts (like /home/root/start.sh). And
THAT's why I wrote it in the first place: to activate special things by holding a button while booting...
ANY idea what might be happening? The program always returns 'FF', no key pressed...
EDIT: when I do a lsmod just before calling buttoncheck, I see tha the button module is loaded...