Comments (12)
What type of system is the error occurring on? A Raspberry Pi 0, 1, 2, 3 or 4? A BeagleBone? Something else?
If a Raspberry Pi with a 40-pin GPIO header is being used please ensure that the SPI1 peripheral is not activated for usage as activating SPI1 will reserve GPIO20 for SPI thus making it unusable for other purposes.
Please post a complete (but short) program that can be run and used to reproduce the error rather than snippets of code.
Please post the content of /boot/config.txt
from onoff.
If GPIO20 is configured as an output and later configured as an input, calling writeSync
for GPIO20 will result in an EPERM
error. This is to be expected as it's not permitted to call writeSync
for a GPIO configured as an input.
For example, running this program:
const Gpio = require('onoff').Gpio;
const relay2 = new Gpio(20, 'out');
const input = new Gpio(20, 'in');
function a() {
relay2.writeSync(1);
}
a();
results in this EPERM
error:
internal/fs/utils.js:259
throw err;
^
Error: EPERM: operation not permitted, write
at Object.writeSync (fs.js:694:3)
at Gpio.writeSync (/home/pi/onoff/node_modules/onoff/onoff.js:243:8)
at a (/home/pi/onoff/t.js:7:10)
at Object.<anonymous> (/home/pi/onoff/t.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -1,
syscall: 'write',
code: 'EPERM'
}
Perhaps your program is configuring GPIO20 first as an output, then as an input and the calling writeSync
from onoff.
@rajanlagah Any news on this one?
from onoff.
I do have
var relay2 = new Gpio(20, 'out');
and then
function enable( ){
if(stage == 1){
relay2.writeSync(1);
}
if(stage == 2){
liveD.writeSync(1);
}
if(stage == 3){
relay2.writeSync(0);
}
if(stage == 4){
liveD.writeSync(1);
}
if(stage < 4){
setTimeout(enable(stage+1),500)
}
}
As you can see i am performing only writeSync
from onoff.
As mentioned above, please post a complete (but short) program that can be run and used to reproduce the error rather than snippets of code.
I'm afraid I can't provide any help without a complete (but short) program that can be used to reproduce the error.
Edit: This line of code is most likely not doing what you think it is doing:
setTimeout(enable(stage+1),500)
from onoff.
const LCD = require('lcdi2c');
var Gpio = require('onoff').Gpio; //include onoff to interact with the GPIO
var liveA = new Gpio(21, 'out');
var liveB = new Gpio(26, 'out');
var liveC = new Gpio(19, 'out');
var liveD = new Gpio(13, 'out');
var relay1 = new Gpio(16, 'out');
var relay2 = new Gpio(20, 'out');
function enable( ){
if(stage == 1){
relay2.writeSync(1);
}
if(stage == 2){
liveD.writeSync(1);
}
if(stage == 3){
relay2.writeSync(0);
}
if(stage == 4){
liveD.writeSync(1);
}
if(stage < 4){
setTimeout(enable(stage+1),500)
}
}
enable()
This is my short code
from onoff.
What is the output of that program when you run it?
Were is stage defined?
from onoff.
var blinkInterval = "" // setInterval(blinkLED, 500); //run the blinkLED function every 250ms
var stepNumber = 0;
function blinkLED() { //function to start blinking
if (stepNumber == 0) {
relay2.writeSync(1);
vending = true;
console.log("Turned off card");
stepNumber = 1;
} else if(stepNumber == 1){
relay2.writeSync(0);
stepNumber = 2;
console.log("Turned on card");
endBlink();
}
}
function endBlink() { //function to stop blinking
clearInterval(blinkInterval); // Stop blink intervals
relay2.writeSync(0);
console.log("Completed routine");
}
setTimeout(endBlink, 1000*60*5);
function enable( ){
blinkInterval = setInterval(blinkLED, 500);
}
enable()
Another way of doing that but having same issue
from onoff.
What is the output of that program when you run it?
Were is stage defined?
Yes yes it was a global variable
later we did this
function enable( stage=1){
from onoff.
What is the output of this program when you run it?
from onoff.
internal/fs/utils.js:259
throw err;
^
Error: EPERM: operation not permitted, write
at Object.writeSync (fs.js:694:3)
at Gpio.writeSync (/home/pi/onoff/node_modules/onoff/onoff.js:243:8)
at a (/home/pi/onoff/t.js:7:10)
at Object.<anonymous> (/home/pi/onoff/t.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -1,
syscall: 'write',
code: 'EPERM'
}
THIS
from onoff.
That is not the output. That was copied that from here. I'm afraid I can't provide any further help, good luck.
from onoff.
Related Issues (20)
- Problem using watch function with relay HOT 10
- Initialize GPIO without change pin status. HOT 6
- GPIO not working in a worker_thread - nodejs 14.15 HOT 2
- EACCES: permission denied, open '/sys/class/gpio/export' as superuser HOT 2
- Cannot run on non Rpi system HOT 1
- TypeError: writeSync is not a function HOT 4
- Raspberry Pi GPIO control in electron App HOT 8
- My computer does not have a /sys/class/gpio directory, but has /dev/gpiochip* HOT 1
- Interrupt misfire HOT 3
- Raspberry 4 - malloc(): corrupted top size HOT 3
- Error: EPERM: operation not permitted, write HOT 4
- Does not work with Compute Module 4. HOT 2
- Event is fired multiple times
- Superb library - I am running on Node v20 HOT 2
- Pi 5 Compatibility issues HOT 9
- Compatibility with ppp asked?
- RPI 5 gpio numbers HOT 1
- fs error HOT 6
- Newer version of epoll
- Button.watch spams endlessly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onoff.