c - 接线PiISR : No such file or directory

标签 c interrupt wiringpi orange-pi

我正在尝试在 Orange Pi Plus H3 上使用中断。我已从 here 下载了 WiringOP并安装了它。

但是当我运行程序时,我收到消息:

gpio:无法打开GPIO导出接口(interface):没有这样的文件或目录 WiringPiISR:无法打开/sys/class/gpio/gpio7/value:没有这样的文件或目录

我发现了很多类似的问题,但没有一个解决方案不适合我。例如,在/boot/config.txt 中进行更改,但在我的/boot/目录中我没有 config.txt 文件等。

有什么办法可以解决这个问题吗?

这是我测试过的代码:

#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;
}

我的系统是 Lubuntu 15.04,使用 Loboris 的修改内核。

最佳答案

嗯。经过长时间与 OrangePI 的合作,找到了解决方案。

在 Orange Pi 上使用中断的唯一方法是安装 Armbian 。然后安装this version of WiringOP最后克隆这个:https://github.com/ua3nbw/gpiokey

将会有wpi.c文件。使用gcc编译它并在您选择的引脚上进行中断(默认 - 引脚8)。

不幸的是,我的 Orange 在第一次中断后 5 秒就关闭了。也许稍后我会找到解决这个问题的方法。

关于c - 接线PiISR : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38420725/

相关文章:

gpio - 将 Raspberry 硬件 GPIO 引脚映射到 gpiod 芯片线号

c - 一个计算大数阶乘的程序

计算不以句点结尾的段落,C 语言

java - 中断长工作线程

linux - system() 调用的 WiringPi gpio 必须使用另一个进程?

c - 为什么 WiringPiISR 在被触发时不阻塞主例程?

c - 在循环内或循环外声明变量,有很大区别吗?

c - 逐个元素读取有效,但读取 block 则无效

java - ThreadPoolTask​​Executor 优雅关闭

java - 设置中断位不会使 Future.get() 抛出 TimeoutException