askrav
askrav

Reputation: 203

wiringPiISR: No such file or directory

I'm trying to use interrupts on my Orange Pi Plus H3. I've dowloaded WiringOP from here and installed it.

But when I'm running program, I got the message:

gpio: Unable to open GPIO export interface: No such file or directory wiringPiISR: unable to open /sys/class/gpio/gpio7/value: No such file or directory

I've found a lot of similar problems but no one solution does not fit me. For example make changes in /boot/config.txt, but in my /boot/ dir I haven't got config.txt file etc.

Are there any ways to solve this?

And here is the code I've tested:

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>

// WPi 7 to PA7, ie. Physical OPi-pin 29||WPi 8 to PA8, ie. Physical OPi-pin 31||WPi 9 to PG08 OPi-pin 32||
// WPi 10 to PA09 OPi-pin 33|| WPi 12 to PPA10 OPi-pin 35  || WPi 15 to PG06 OPi-pin 38                     
#define BUTTON_PIN 8

// the event counter
volatile int eventCounter = 0;

// -------------------------------------------------------------------------

void myInterrupt(void) {
  eventCounter++;
}

// -------------------------------------------------------------------------

int main(void) {

  // sets up the wiringPi library
  if (wiringPiSetup () < 0) {
    fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
    return 1;
  }
  pinMode(BUTTON_PIN, INPUT);
  pullUpDnControl (BUTTON_PIN, PUD_UP) ;

  if ( wiringPiISR (BUTTON_PIN, INT_EDGE_FALLING, &myInterrupt) < 0 ) {
    fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
    return 1;
  }

  // display counter value every second.
  while ( 1 ) {
    //  printf( "%d\n", eventCounter );
    if (eventCounter != 0) {
      system("systemctl suspend");
      //printf("Error!!!");
    }

    eventCounter = 0;
    delay( 100 ); // wait 0.1 second
  }

  return 0;
}

My system is Lubuntu 15.04 using Loboris' modified kernel.

Upvotes: 0

Views: 930

Answers (1)

askrav
askrav

Reputation: 203

Well, after a long time working with OrangePI solution has been found.

The only way to use interrupts on Orange Pi is installing Armbian. Then install this version of WiringOP and finally clone this: https://github.com/ua3nbw/gpiokey

There will be wpi.c file. Compile it using gcc and make interrupts on the pin you choose (default - pin 8).

Unfortunately, my Orange is shutting down 5 seconds after the first interrupt. Maybe later I'll find the way to fix this.

Upvotes: 0

Related Questions