Getting Error EBUSY: resource busy or locked

前端 未结 7 1519
南笙
南笙 2021-02-15 15:41

Trying to run a Nodejs app to test Raspberry 3 B + Gpio Onoff Module but when i am trying to run the app getting this Error

fs.js:114
throw err;

Error: EBUSY: r         


        
7条回答
  •  梦谈多话
    2021-02-15 15:56

    var onoff = require('onoff');
    var Gpio = onoff.Gpio,
        led = new Gpio(4, 'out'),
        interval;
    interval = setInterval(function () {
        var value = (led.readSync() + 1) % 2;
        led.write(value, function () {
            console.log("Changed LED state to: " + value);
        });
    }, 2000);
    process.on('SIGINT', function () {
        clearInterval(interval);
        led.writeSync(0);
        led.unexport();
        console.log('Bye, bye!');
        process.exit();
    });
    

提交回复
热议问题