You are reading a single comment by @Andrey and its replies. Click here to read the full conversation.
  • 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,2], [0,0,0,0,1]);
    }
    
    function ledOn(){
      on=!on;
      digitalWrite(B8,on);
      nrf.sendString("digitalWrite(B8,"+on+")"­);
      digitalWrite(B9,on);
      //nrf.sendString("digitalWrite(B9,"+on+"­)");
      digitalWrite(B6,!on);
      //nrf.sendString("digitalWrite(B6,"+!on+­")");
    
    }
    
    //onInit();
    setInterval(function() {
      ledOn();
      
    }, 1000);
    

    and reciever with modified slaveHandler method:

    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,digitalW­rite(B8,digitalWrite(B8,digitalWrite(B8,­digitalWrite(B8,digitalWrite(******
    
    //  lots of It //
    
    ******(B8,digitalWrite(B8,digitalWrite(B­8,digitalWrite(B8,digitalWrite(B8,digita­lWrite(B8,digitalWrite(B8,digitalWrite(B­8,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 ?

About

Avatar for Andrey @Andrey started