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

Fixes #43 How to release a wiringPiI2CSetup() file descriptor #50

Merged
merged 1 commit into from
Sep 29, 2016

Conversation

NoHomey
Copy link
Collaborator

@NoHomey NoHomey commented Sep 29, 2016

I've searched WiringPi's src for functions that open a file descriptor and found that only SPI and I2C interfaces opens file descriptor by making call to open for which there is no corresponding disposing function, since in C/C++ it is expected close to be used like @nekuz0r pointed in #43.

The search showed that currently wiirngPiI2cSetup makes a call to wiringPiI2CSetupInterface which dose an open and wiringPiSPISetup makes a call to wiirngPiSPISetupMode which dose an open.

I've decided to add separate closing function for each communication interface instead of one core close for both since Serial has it's own serialClose and some one may potentially decide to close the opened file descriptor by making a call to that open function instead of serialClose ...

So with this PR I'm adding:

  • wiringPiI2CClose for releasing opened file descriptor from wiringPiI2CSetup or wiringPiI2CSetupInterface.
  • wiringPiSPIClose for releasing opened file descriptor from wiringPiSPISetup or wiringPiSPISetupMode.

Both functions share a redundant implementation but having one separate implementation in nodemodule namespace would require manually writing function's implementation and exporting under different name using v8 members which in my opinion contrasts with the whole idea of addon.h beeing declaritive and unified framework for writing WiringPi's node addon ...

@nekuz0r
Copy link
Collaborator

nekuz0r commented Sep 29, 2016

@NoHomey Great job, exactly what i had in mind

@nekuz0r nekuz0r merged commit bf14d46 into WiringPi:master Sep 29, 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.

2 participants