node-libgpiod icon indicating copy to clipboard operation
node-libgpiod copied to clipboard

When importing mysql2 and setting the value of lines in a setInterval it gives an EPERM error

Open LaurentDhont opened this issue 1 year ago • 3 comments

This is a very strange issue, see below a piece of code that works, but when you require('mysql2') it stops working and gives the following error:

Error: EPERM, Operation not permitted
    at Timeout.main [as _onTimeout] (test.js:9:7)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  errno: 1,
  code: 'EPERM',
  syscall: '::setValue'
}

Also worth to mention is that this error only occurs when requiring mysql2 and calling the setValue in a setTimeout or setInterval

Code:

const lib = require('node-libgpiod');
const mysql2 = require('mysql2'); // when commenting this line everything works fine
const chip = new lib.Chip(4);
const line = new lib.Line(chip, 26);
line.requestOutputMode(0);

function main() {
        line.setValue(1);
}

setTimeout(main, 1000 * 30);

Versions: Node: v20.13.1 mysql2: 3.9.8 node-libgpiod: 0.4.3 ubuntu: Ubuntu 24.04 LTS Raspberry Pi 5B rev 1.0

LaurentDhont avatar May 28 '24 21:05 LaurentDhont

Hello @LaurentDhont Thanks for report this, i'll investigate as soon as i get the work on gpiosim done.

sombriks avatar Jun 01 '24 11:06 sombriks

@sombriks Is there anything I can do to fix this or to make it work?

LaurentDhont avatar Jun 06 '24 11:06 LaurentDhont

Hello @LaurentDhont ,

indeed an odd issue, you can help me out to debug it by cloning the examples repository and running this one: https://github.com/sombriks/node-libgpiod-examples/tree/main/database-read-pin-write

i am still configuring other real hardware environments, but i was unable to reproduce the issue on my virtual machine or in my raspberry pi zero w (32 bits running raspbian 12 / node 18)

i still have a rasberry pi model 3 B+ to test and my new board, a raxda rock 3C, but i don't have a raspberry pi 5 at hand.

let me know when you have a moment to spare and try the sample code i built to explore this issue.

sombriks avatar Jun 30 '24 16:06 sombriks

tested the sample project against latest release and it still works.

sombriks avatar May 18 '25 19:05 sombriks