You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to test my spi with this loopback script
var rpio = require('rio');
var rxBuffer = rpio.spiTransfer(new Buffer('HELLOSPI'), 8);
for (var i = 0; i <= 7; i++) {
process.stdout.write(String.fromCharCode(rxBuffer[i]) + (i == 7 ? '\n' : ' '));
};
but i get this error.
/home/pi/Railway/node_modules/rpio/lib/rpio.js:641
return binding.spi_transfer(txbuf, rxbuf, len);
^
TypeError: Incorrect arguments
at TypeError (native)
at rpio.spiTransfer (/home/pi/Railway/node_modules/rpio/lib/rpio.js:641:17)
at Object.<anonymous> (/home/pi/Railway/spitest.js:5:21)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
The text was updated successfully, but these errors were encountered:
Hi! The API changed in recent versions so that the rxBuffer argument is now part of the function call. You would also need to allocate the buffer first, the binding won't do it for you and expects an existing Buffer to be provided.
So, something like:
var rxBuffer = new Buffer(8)
rpio.spiTransfer(new Buffer('HELLOSPI'), rxBuffer, 8)
Hope that helps, and sorry for the change, but it's part of making the API more orthogonal, and allows for a future version to return the number of bytes read if that proves to be useful.
Im trying to test my spi with this loopback script
but i get this error.
The text was updated successfully, but these errors were encountered: