Fixes #43 How to release a wiringPiI2CSetup() file descriptor #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've searched
WiringPi
'ssrc
for functions thatopen
a file descriptor and found that onlySPI
andI2C
interfaces opens file descriptor by making call toopen
for which there is no corresponding disposing function, since in C/C++ it is expectedclose
to be used like @nekuz0r pointed in #43.The search showed that currently
wiirngPiI2cSetup
makes a call towiringPiI2CSetupInterface
which dose anopen
andwiringPiSPISetup
makes a call towiirngPiSPISetupMode
which dose anopen
.I've decided to add separate closing function for each communication interface instead of one core
close
for both sinceSerial
has it's ownserialClose
and some one may potentially decide to close the opened file descriptor by making a call to thatopen
function instead ofserialClose
...So with this PR I'm adding:
wiringPiI2CClose
for releasing opened file descriptor fromwiringPiI2CSetup
orwiringPiI2CSetupInterface
.wiringPiSPIClose
for releasing opened file descriptor fromwiringPiSPISetup
orwiringPiSPISetupMode
.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 usingv8
members which in my opinion contrasts with the whole idea ofaddon.h
beeing declaritive and unified framework for writingWiringPi
's node addon ...