【问题标题】:wiringPiISR: No such file or directory接线PiISR:没有这样的文件或目录
【发布时间】:2016-11-20 02:48:25
【问题描述】:

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

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

gpio: 无法打开 GPIO 导出接口: 没有那个文件或目录 接线PiISR:无法打开/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 修改过的内核。

【问题讨论】:

  • 我的系统是来自 Loboris 的 Lubuntu 15.04
  • 您正在使用的系统等信息应该放在问题本身中,而不是在 cmets 中。我为你编辑了它。顺便说一句,一些mod可以删除这两个cmets吗?

标签: c interrupt wiringpi orange-pi


【解决方案1】:

嗯。用了很长时间,终于找到了OrangePI的解决方案。

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

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

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

【讨论】:

  • 修复:在使用中断之前使用“gpio export [pin num]”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-24
  • 2015-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-27
相关资源
最近更新 更多