jperkin / node-rpio

Raspberry Pi GPIO library for node.js
858 stars 124 forks source link

Option for rpio.open to override sys value #64

Open ghost opened 6 years ago

ghost commented 6 years ago

Current code throws an error if a pin that is already defined in /sys/class/gpio is attempted to be opened

IMO, the default behavior should be to unexport the /sys value and proceed with /dev/*mem

I was wondering if enough people would be interested in having an 'override_sys' opt in rpio.init, and if so, would you agree that the default value should be true?

Approximate unexport code that would be added to rpio.prototype.open:

fs.writeFile('/sys/class/gpio/unexport', gpiopin, function(err) { if (cb) return cb(err); });

jperkin commented 5 years ago

Yeh it seems reasonable to add an override. I'll take a shot at this sometime.