0

I am working on my Raspberry pi-4 with JavaScript and pigpio module ,i found problems with interrupt ,

  1. if you start interruption (by button for exp ) it will start a code , but if new interruption comes nothing will happen until the code of the first interruption ends ( why the interruption has no priority on his own called code !?)
  2. if while loop (infinite one : like while (1) ) exist in the main code the interruption will no longer work !

As far as i know that IRQ interruption has priority on every thing in code . but this is not happen !

const Gpio = require('pigpio').Gpio;
var i =0 ;

const button = new Gpio(15, {
  mode: Gpio.INPUT,
  pullUpDown: Gpio.PUD_DOWN,
  edge: Gpio.FALLING_EDGE});

button.on('interrupt', (level) => {
  console.log(i+=1)
  rpio.sleep(5)});

// while(1){}
0ussama
  • 21
  • 3
  • if `rpio.sleep(5)` is blocking (for 5 seconds?), then of course nothing can happen while that is running - javascript has only one thread of execution - why do you need rpio.sleep at all/ – Bravo Aug 15 '21 at 02:50
  • @Bravo It is for my project ... I need to interrupt then go to interruption code and what ever code it takes time if interruption comes again i need to restart the code again (interrupt the old interruption) – 0ussama Aug 15 '21 at 03:10
  • It makes no sense to block execution - javascript has a single thread of execution, so while execution is blocked, nothing else will run, that's how javascript works - perhaps Python, C or C++ would be a better choice for your project – Bravo Aug 15 '21 at 03:14
  • @ thanks for your advice , but is there a way to cut off this delay time (at detection external signal , button for exp ) ? i' am electronic engineer by the way , and as far as i know that IRQ interrupt can stop what ever code is doing then run a function , if the code of interruption is end and there is no new interruption the code return at the same point he stopped from and continue ..... – 0ussama Aug 15 '21 at 03:22
  • `IRQ interrupt can stop what ever code is doing` not sure that's compatible with how javascript works though – Bravo Aug 15 '21 at 03:24

0 Answers0