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 nodemodulenamespace 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 ...
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 ...