Skip to content

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

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

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

Conversation

@SpComb

@SpComb SpComb commented Jun 22, 2016

Copy link
Copy Markdown

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

tve commented Sep 9, 2016

Copy link
Copy Markdown
Contributor

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

SpComb commented Sep 9, 2016

Copy link
Copy Markdown
Author

That sounds like it would also work just as well.

@wiless

wiless commented Sep 9, 2016

Copy link
Copy Markdown
Contributor

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

@tve

tve commented Sep 9, 2016

Copy link
Copy Markdown
Contributor

@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

wiless commented Sep 9, 2016

Copy link
Copy Markdown
Contributor

@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

tve commented Sep 25, 2016

Copy link
Copy Markdown
Contributor

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