Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CrossNiGao opened this issue Jun 19, 2024 · 0 comments

Comments

@CrossNiGao
Copy link

重新启动后首次运行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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant