WiringPi / WiringPi-Node

Node.js bindings to wiringPi
333 stars 94 forks source link

returning from wiringPiSPIDataRW #85

Closed eczajk1 closed 6 years ago

eczajk1 commented 6 years ago

I am using the following function to try to read from the SPI bus on RaspberryPi3:

wpi.wiringPiSPIDataRW(1, new Buffer([0xFF]));

... this evaluates to an integer that seems to be equal to the length of my buffer (1 in this case). I guess I don't understand if there is something different I need to be doing with the 2nd parameter here.

For context, I am trying to emulate what this Python library is doing:

https://github.com/ul-gh/PiPyADC/blob/3f9ccd83a7680652255d3909d082d9b14176e289/pipyadc.py#L358-L370

eczajk1 commented 6 years ago

Nevermind, I get it now:

var myBuf = new Buffer([0xFF]);
wpi.wiringPiSPIDataRW(1, myBuf);
return myBuf[0];