Skip to content

digitalPin: do not export if the /sys/class/gpio/... file already exists#61

Closed
SpComb wants to merge 2 commits intokidoman:masterfrom
SpComb:digitalpin-exported
Closed

digitalPin: do not export if the /sys/class/gpio/... file already exists#61
SpComb wants to merge 2 commits intokidoman:masterfrom
SpComb:digitalpin-exported

Conversation

@SpComb
Copy link

@SpComb SpComb commented Jun 22, 2016

Change digitalPin to allow the use of an already exported gpio pin, avoiding the write /sys/class/gpio/export: device or resource busy errors that currently result. This kind of situation is easy to end up in if you e.g. kill the process and restart it, without giving it a chance to unexport its pins.

This should suffice to handle the issues mentioned in #30 and #44.

This also helps to deal with the open /sys/class/gpio/gpio21/direction: permission denied races in #52, by allowing us to use a helper script to pre-export the gpio pins and wait for udev to settle.

@SpComb SpComb mentioned this pull request Jun 22, 2016
@tve
Copy link
Contributor

tve commented Sep 9, 2016

I've taken a slightly different approach in #67, which is to ignore the error if the pin has already been exported. This way it's only one system call.

@SpComb
Copy link
Author

SpComb commented Sep 9, 2016

That sounds like it would also work just as well.

@wiless
Copy link
Contributor

wiless commented Sep 9, 2016

I used to workaround catching os signal, and unexporting in init through cmd.exec

@tve
Copy link
Contributor

tve commented Sep 9, 2016

@wiless I don't understand. The fix in #69 is 091d6f5, I'm not sure what signals or cmd.exec have to do with that...

@wiless
Copy link
Contributor

wiless commented Sep 9, 2016

@tve I meant to say was my workaround to handle unexported GPIO issue

  • In the beginning of my application , I monitor the interrupts from os/signal and "unexport" before terminating application.
  • Also in the init() I attempt to unexport the GPIO through calling echo 1 > /sys/class/gpio.. through cmd.exec. This ensures that the error is avoided.

@tve
Copy link
Contributor

tve commented Sep 25, 2016

I'm pretty convinced that this is taken care of by #69. Please reopen with an example if it's not.

@tve tve closed this Sep 25, 2016
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

Successfully merging this pull request may close these issues.

3 participants