orangepi-xunlong / wiringOP

wiringPi for Orange Pi
GNU Lesser General Public License v3.0
394 stars 189 forks source link

first time calling wiringPiISR from boot get error 启动后初次运行wiringPiISR会报错 #110

Open CrossNiGao opened 2 months ago

CrossNiGao commented 2 months ago

重新启动后首次运行wiringPiISR会报错: If you run wiringPiISR for the first time after restarting, an error will be reported: wiringPiISR: unable to open /sys/class/gpio/gpioXX/value 但是去看这个路径,文件实际上就是生产了,而且不运行这句话就不会生成,我判断可能是生产的时间比代码运行的时间要晚了一些。 But if you look at this path, the file is actually produced, and it won't be generated if you don't run this API, so I think it may be that the production time is a little later than the code run. 所以我尝试在代码wiringPi.c那边增加了一次的再运行功能: So I tried to add a retry once to the wiringPi.c file:

if (sysFds [bcmGpioPin] == -1) { sprintf (fName, "/sys/class/gpio/gpio%d/value", bcmGpioPin) ; if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0) { delay(1*1000); if ((sysFds [bcmGpioPin] = open (fName, O_RDWR)) < 0) return wiringPiFailure (WPI_FATAL, "wiringPiISR: unable to open %s: %s\n", fName, strerror (errno)) ; }

} 这下就不会再出现问题了。这应该是个BUG,请修正。 There will be no more problems now. this should be a BUG, please fix it.