Home arrow Support arrow Product Support arrow LinuxBox LB1 (Embedded-PC) arrow Documentation arrow Button state analyzing

Button State Query


There is a push-button on the LinuxBox which can be user-specifically evaluated.
To determine the button state use the following command:


readbits -p a -b 1


Pressing the push-button prompts the program to yield a "0" signal.
Subsequent resetting yields "1".

The button is connected with GPIO Port A and Bit 1.

In -C- the button can be querried as follows:

#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/ioctl.h"
#include "fcntl.h"
#include "asm/etraxgpio.h"

int main(void)
{

int fd;
int value;
int iomask;
if ((fd = open("/dev/gpioa", O_RDWR))<0)
{
printf("Open error on /dev/gpiog\n");
exit(0);
}
iomask=1<<1;
printf("Press the button...\n");
while (1)
{
value=ioctl(fd, _IO(ETRAXGPIO_IOCTYPE, IO_READBITS));
if ((value&iomask)==0) {
   printf("Button pressed\n");
}
sleep(1);
}
}


<<
↑


ipcas GmbH is a member of Data Respons Group


Copyright 1988 - 2010 ipcas GmbH

Gundstrasse 15 D-91056 Erlangen Tel.: +49 (0)9131/ 7677-0 Fax: +49 (0)9131/ 7677-78 E-Mail: info@ipcas.de