here is the test case with 2xNRF modules: 2 F4 discovery boards with very simple program. It repeats the state of B8 pin on another board. Sender side:
SPI1.setup({sck:A5, miso:A6, mosi:A7});
var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
function onInit() {
E.enableWatchdog(20);
Serial1.setConsole();
nrf.setTXPower(2);
nrf.setDataRate(250000);
nrf.init([0,0,0,0,1], [0,0,0,0,2]);
}
function slaveH(){
while (nrf.getDataPipe()!==undefined) {
var data = nrf.getData();
for (var i in data) {
var ch = data[i];
if (ch===0 && nrf.cmd!=="") {
var c = nrf.cmd;
nrf.cmd = "";
//var nrf = this;
/** evaluate and return a result in the timeout,
so that evaluation errors don't cause the slaveHandler
interval to get removed */
setTimeout(function() {
print(""+c);
var result = ""+eval(c); // evaluate
//print("...="+result);
// send the result back after a timeout
}, 1);
} else if (ch!==0) {
nrf.cmd += String.fromCharCode(ch);
}
}
}
}
//onInit();
setInterval(function() {
slaveH();
}, 50);
It works well, but after ~10 minutes reciever stops with the message:
Execution Interrupted during event processing.
Uncaught SyntaxError: Got ?[128] expected EOF
at line 1 col 1
^
in function called from system
Execution Interrupted during event processing.
Uncaught SyntaxError: Got ?[128] expected EOF
at line 1 col 1
^
in function called from system
digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(******
// lots of It //
******(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,digitalWrite(B8,d
seems to some buffer overflow or someth similar. Nrf addressing looks well. Bad thing is, that I can't launch It again: clearInterval() and setInterval(){function(){slaveH();},50); didn't start It.
What is the problem ?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
here is the test case with 2xNRF modules: 2 F4 discovery boards with very simple program. It repeats the state of B8 pin on another board. Sender side:
and reciever with modified slaveHandler method:
It works well, but after ~10 minutes reciever stops with the message:
seems to some buffer overflow or someth similar. Nrf addressing looks well. Bad thing is, that I can't launch It again:
clearInterval()
andsetInterval(){function(){slaveH();},50);
didn't start It.What is the problem ?