From: Patrick M. <pma...@dr...> - 2011-02-10 17:23:19
|
I don't know if this helps, but you should not mix stream I/O (fopen) low level I/O (read). Try openning the file using: fd = open("/dev/gpio-event", O_RDONLY); to get a file descriptor, fd. Then use fd where you fileno(fs_event). Patrick ________________________________ From: Mathias Kriebel [mailto:mat...@ho...] Sent: February 10, 2011 11:51 To: gum...@li... Subject: Re: [Gumstix-users] gpio-event problems in C Forgot to show how I am using it in the program. Here it is: system("insmod gpio-event-drv.ko"); if (( fs_event = fopen( "/dev/gpio-event", "r" )) < 0 ) { perror( "Unable to open /dev/gpio-event" ); exit( 1 ); } GPIO_EventMonitor_t monitor; monitor.gpio = ECHO; monitor.onOff = 1; monitor.edgeType = GPIO_EventBothEdges; monitor.debounceMilliSec = 1; if ( ioctl( fileno( fs_event ), GPIO_EVENT_IOCTL_MONITOR_GPIO, &monitor ) != 0 ) { perror( "ioctl GPIO_EVENT_IOCTL_MONITOR_GPIO failed" ); } And then: int value; read(fileno(fs_event), &value, 1); ________________________________ From: mat...@ho... To: gum...@li... Date: Thu, 10 Feb 2011 14:42:41 -0200 Subject: [Gumstix-users] gpio-event problems in C Hello I have tested gpio-event and it works well using " cat /dev/gpio-event ". However when I use it in a C program it waits until a signal is detected then it just keep receiving non-existent signals. I want to measure the width of a pulse, detecting the rising edge, getting the current time, detecting the falling edge and again detecting the falling edge. Does someone knows why is this happening and what could be done? Thanks Mathias ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ gumstix-users mailing list gum...@li... https://lists.sourceforge.net/lists/listinfo/gumstix-users |