The local intHandler function inside attachInterrupt contains:
m.value = parseInt(Number(gpioInt[n].value), 2);
I was honestly surprised this even works at all since gpioInt[n].value is a Buffer here, and passing it to Number() makes no sense. Apparently however it just stringifies the buffer and then converts that to number. Of course passing a number to parseInt() also makes little sense, it will again stringify it and again convert it to a number.
I'd suggest changing it to parseInt(gpioInt[n].value.toString(), 2) to clarify what it's doing and avoid two pointless conversions.
From @mvduin on April 24, 2018 4:45
The local
intHandler
function insideattachInterrupt
contains:I was honestly surprised this even works at all since
gpioInt[n].value
is a Buffer here, and passing it to Number() makes no sense. Apparently however it just stringifies the buffer and then converts that to number. Of course passing a number to parseInt() also makes little sense, it will again stringify it and again convert it to a number.I'd suggest changing it to
parseInt(gpioInt[n].value.toString(), 2)
to clarify what it's doing and avoid two pointless conversions.Copied from original issue: jadonk/bonescript#163