Avatar for #kai

#kai

Member since Jan 2014 • Last active Jun 2014
  • 0 conversations
  • 7 comments

Most recent activity

  • in General
    Avatar for #kai

    After using the non-mimified version and cleaning up those inline "/..../" comments the modules does seem to work now. But only with the addition of the "baud:100000" parameter to the SPI module.

  • in General
    Avatar for #kai

    Here i am back with what @Gordon did suggest. First I did deletie the installed Web IDE from Google Chrome (). Then after downloading the Web IDE from GitHub using the ZIP file, I did unpack and install it. Now i have Version 0.32.0 installed.

    After launching the new Web IDE I did send my code as listed above to the Espruino board and my console contains the following. Seems to be correct to me in the console, but unfortunately the Espruino console still shows the same errors as in my previous posts :-/

    >>> Connecting espruino_status.js:40
    Set Slow Write = true espruino_serial.js:170
    Object
    bitrate: 9600
    bufferSize: 4096
    connectionId: 2
    ctsFlowControl: false
    dataBits: "eight"
    name: ""
    parityBit: "no"
    paused: false
    persistent: false
    receiveTimeout: 0
    sendTimeout: 0
    stopBits: "one"
    __proto__: Object
     espruino_serial.js:62
    Device found (connectionId=2) terminal.js:41
    >>> Sending... espruino_status.js:40
    Sending "\u0003echo(0);\nconsole.log(\"<<\"+\"<<­<\"+JSON.stringify(process.env)+\">>>\"+­\">>\");\n" espruino_serial.js:115
    >>> Sent espruino_status.js:40
    Got "echo(0);\r\n<<<<<{\"VERSION\":\"1v48\",­\"BUILD_DATE\":\"Jan 30 2014\",\"BUILD_TIME\":\"13:32:24\",\"BOA­RD\":\"ESPRUINOBOARD\",\"CHIP\":\"STM32F­103RCT6\",\"CHIP_FAMILY\":\"STM32F1\",\"­FLASH\":262144,\"RAM\":49152}>>>>>\r\n" espruino_process.js:47
    >>> Connected espruino_status.js:40
    FIRMWARE: Current 1v48, Available 1v48 espruino_flasher.js:363
    Firmware >1.43 supports faster writes espruino_flasher.js:367
    Set Slow Write = false espruino_serial.js:170
    watt nu 42 USART 0 
    Array[2]
     espruino_board.js:328
    watt nu 43 USART 0 
    Array[2]
     espruino_board.js:328
    watt nu 44 USART 0 
    Array[2]
     espruino_board.js:328
    watt nu 50 USART 0 
    Array[2]
     espruino_board.js:328
    Config.set(code, SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect(SPI1, B0, B1);
    function onInit() {
      print(nrf);
      if (typeof nrf != "undefined") {
        nrf.init([0,0,0,0,1], [0,0,0,0,2]);
        print("NRF Library loaded!");
      } else {
        print("Error! NRF Library not loaded!");
      }
    }
    onInit();
    setInterval(function() {
        nrf.slaveHandler();
    }, 50);) espruino_config.js:61
    loadModule(NRF24L01P) espruino_modules.js:75
     - NRF24L01P requires [] espruino_modules.js:94
    Sending... Modules.removeAllCached();Modules.addCac­hed("NRF24L01P","function NRF(a,b,c,d){this.CSN=b;this.CE=c;this.P­AYLOAD=d?d:16;this.BASE_CONFIG=8;this.cm­d=\"\";this.spi=a;this.callbacks=[]}NRF.­prototype.C={CONFIG:0,STATUS:7,CD:9,RX_A­DDR_P0:10,RX_ADDR_P1:11,TX_ADDR:16,RX_PW­_P0:17,RX_PW_P1:18,R_REGISTER:0,W_REGIST­ER:32,R_RX_PAYLOAD:97,W_TX_PAYLOAD:160,F­LUSH_TX:225,FLUSH_RX:226};\nNRF.prototyp­e.init=function(a,b){digitalWrite(this.C­E,0);digitalWrite(this.CSN,1);this.setRX­Addr(a);this.setTXAddr(b);this.setReg(th­is.C.RX_PW_P0,this.PAYLOAD);this.setReg(­this.C.RX_PW_P1,this.PAYLOAD);this.setRe­g(this.C.CONFIG,this.BASE_CONFIG|3);digi­talWrite(this.CE,1)};NRF.prototype.setRe­g=function(a,b){this.spi.send([this.C.W_­REGISTER|a,b],this.CSN)};NRF.prototype.s­etAddr=function(a,b){b=b.clone();b.splic­e(0,0,this.C.W_REGISTER|a);this.spi.send­(b,this.CSN)};\nNRF.prototype.setRXAddr=­function(a){this.setAddr(this.C.RX_ADDR_­P1,a)};NRF.prototype.setTXAddr=function(­a){this.setAddr(this.C.RX_ADDR_P0,a);thi­s.setAddr(this.C.TX_ADDR,a)};NRF.prototy­pe.getReg=function(a){return this.spi.send([this.C.R_REGISTER|a,0],th­is.CSN)[1]};NRF.prototype.getAddr=functi­on(a){a=this.spi.send([this.C.R_REGISTER­|a,0,0,0,0,0],this.CSN);a.splice(0,1);re­turn a};NRF.prototype.getStatus=function(a){r­eturn this.getReg(this.C.STATUS)};\nNRF.protot­ype.dataReady=function(){return 14!=(this.getReg(this.C.STATUS)&14)};NRF­.prototype.getData=function(){for(var a=[this.C.R_RX_PAYLOAD],b=0;b<this.PAYLO­AD;b++)a.push(0);a=this.spi.send(a,this.­CSN);a.splice(0,1);this.setReg(this.C.ST­ATUS,64);return a};\nNRF.prototype.send=function(a){this­.setReg(this.C.STATUS,48);digitalWrite(t­his.CE,0);this.setReg(this.C.CONFIG,this­.BASE_CONFIG|2);this.spi.send(this.C.FLU­SH_TX,this.CSN);a=a.clone();a.splice(0,0­,this.C.W_TX_PAYLOAD);this.spi.send(a,th­is.CSN);digitalWrite(this.CE,1);for(a=1E­3;a--&&!(this.getReg(this.C.STATUS)&48);­);0>=a&&print(\"TX timeout\");a=!0;this.getReg(this.C.STATU­S)&16&&(print(\"TX not received \"+this.getReg(this.C.STATUS)),a=!1);dig­italWrite(this.CE,0);this.setReg(this.C.­CONFIG,this.BASE_CONFIG|\n3);digitalWrit­e(this.CE,1);this.setReg(this.C.STATUS,4­8);return a};NRF.prototype.slaveHandler=function()­{for(;this.dataReady();){var a=this.getData(),b;for(b in a){var c=a[b];0===c&&\"\"!==this.cmd?(c=this.cm­d,this.cmd=\"\",print(\"...>\"+c),c=\"\"­+eval(c),print(\"...=\"+c),this.sendStri­ngTimeout(c,500)):0!==c&&(this.cmd+=Stri­ng.fromCharCode(c))}}};\nNRF.prototype.m­asterHandler=function(){for(;this.dataRe­ady();){var a=this.getData(),b;for(b in a){var c=a[b];if(0===c&&\"\"!==this.cmd){c=this­.cmd;this.cmd=\"\";var d=this.callbacks.splice(0,1)[0];void 0!==d&&d(c)}else 0!==c&&(this.cmd+=String.fromCharCode(c)­)}}};NRF.prototype.sendString=function(a­){for(var b=0;b<=a.length;b+=this.PAYLOAD){for(var­ c=[],d=0;d<this.PAYLOAD;d++)c[d]=Integer­.valueOf(a[b+d]);for(d=3;0<d--&&!this.se­nd(c););}};NRF.prototype.sendCommand=fun­ction(a,b){this.callbacks.push(b);this.s­endString(a)};\nNRF.prototype.sendString­Timeout=function(a,b){var c=this;setTimeout(function(){c.sendStrin­g(a)},b)};exports.connect=function(a,b,c­,d){return new NRF(a,b,c,d)};\n");
    
    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect(SPI1, B0, B1);
    function onInit() {
      print(nrf);
      if (typeof nrf != "undefined") {
        nrf.init([0,0,0,0,1], [0,0,0,0,2]);
        print("NRF Library loaded!");
      } else {
        print("Error! NRF Library not loaded!");
      }
    }
    onInit();
    setInterval(function() {
        nrf.slaveHandler();
    }, 50); espruino_codewriter.js:42
    >>> Sending... espruino_status.js:40
    Sending "echo(0);\nModules.removeAllCached();Mod­ules.addCached(\"NRF24L01P\",\"function NRF(a,b,c,d){this.CSN=b;this.CE=c;this.P­AYLOAD=d?d:16;this.BASE_CONFIG=8;this.cm­d=\\\"\\\";this.spi=a;this.callbacks=[]}­NRF.prototype.C={CONFIG:0,STATUS:7,CD:9,­RX_ADDR_P0:10,RX_ADDR_P1:11,TX_ADDR:16,R­X_PW_P0:17,RX_PW_P1:18,R_REGISTER:0,W_RE­GISTER:32,R_RX_PAYLOAD:97,W_TX_PAYLOAD:1­60,FLUSH_TX:225,FLUSH_RX:226};\\nNRF.pro­totype.init=function(a,b){digitalWrite(t­his.CE,0);digitalWrite(this.CSN,1);this.­setRXAddr(a);this.setTXAddr(b);this.setR­eg(this.C.RX_PW_P0,this.PAYLOAD);this.se­tReg(this.C.RX_PW_P1,this.PAYLOAD);this.­setReg(this.C.CONFIG,this.BASE_CONFIG|3)­;digitalWrite(this.CE,1)};NRF.prototype.­setReg=function(a,b){this.spi.send([this­.C.W_REGISTER|a,b],this.CSN)};NRF.protot­ype.setAddr=function(a,b){b=b.clone();b.­splice(0,0,this.C.W_REGISTER|a);this.spi­.send(b,this.CSN)};\\nNRF.prototype.setR­XAddr=function(a){this.setAddr(this.C.RX­_ADDR_P1,a)};NRF.prototype.setTXAddr=fun­ction(a){this.setAddr(this.C.RX_ADDR_P0,­a);this.setAddr(this.C.TX_ADDR,a)};NRF.p­rototype.getReg=function(a){return this.spi.send([this.C.R_REGISTER|a,0],th­is.CSN)[1]};NRF.prototype.getAddr=functi­on(a){a=this.spi.send([this.C.R_REGISTER­|a,0,0,0,0,0],this.CSN);a.splice(0,1);re­turn a};NRF.prototype.getStatus=function(a){r­eturn this.getReg(this.C.STATUS)};\\nNRF.proto­type.dataReady=function(){return 14!=(this.getReg(this.C.STATUS)&14)};NRF­.prototype.getData=function(){for(var a=[this.C.R_RX_PAYLOAD],b=0;b<this.PAYLO­AD;b++)a.push(0);a=this.spi.send(a,this.­CSN);a.splice(0,1);this.setReg(this.C.ST­ATUS,64);return a};\\nNRF.prototype.send=function(a){thi­s.setReg(this.C.STATUS,48);digitalWrite(­this.CE,0);this.setReg(this.C.CONFIG,thi­s.BASE_CONFIG|2);this.spi.send(this.C.FL­USH_TX,this.CSN);a=a.clone();a.splice(0,­0,this.C.W_TX_PAYLOAD);this.spi.send(a,t­his.CSN);digitalWrite(this.CE,1);for(a=1­E3;a--&&!(this.getReg(this.C.STATUS)&48)­;);0>=a&&print(\\\"TX timeout\\\");a=!0;this.getReg(this.C.STA­TUS)&16&&(print(\\\"TX not received \\\"+this.getReg(this.C.STATUS)),a=!1);d­igitalWrite(this.CE,0);this.setReg(this.­C.CONFIG,this.BASE_CONFIG|\\n3);digitalW­rite(this.CE,1);this.setReg(this.C.STATU­S,48);return a};NRF.prototype.slaveHandler=function()­{for(;this.dataReady();){var a=this.getData(),b;for(b in a){var c=a[b];0===c&&\\\"\\\"!==this.cmd?(c=thi­s.cmd,this.cmd=\\\"\\\",print(\\\"...>\\­\"+c),c=\\\"\\\"+eval(c),print(\\\"...=\­\\"+c),this.sendStringTimeout(c,500)):0!­==c&&(this.cmd+=String.fromCharCode(c))}­}};\\nNRF.prototype.masterHandler=functi­on(){for(;this.dataReady();){var a=this.getData(),b;for(b in a){var c=a[b];if(0===c&&\\\"\\\"!==this.cmd){c=­this.cmd;this.cmd=\\\"\\\";var d=this.callbacks.splice(0,1)[0];void 0!==d&&d(c)}else 0!==c&&(this.cmd+=String.fromCharCode(c)­)}}};NRF.prototype.sendString=function(a­){for(var b=0;b<=a.length;b+=this.PAYLOAD){for(var­ c=[],d=0;d<this.PAYLOAD;d++)c[d]=Integer­.valueOf(a[b+d]);for(d=3;0<d--&&!this.se­nd(c););}};NRF.prototype.sendCommand=fun­ction(a,b){this.callbacks.push(b);this.s­endString(a)};\\nNRF.prototype.sendStrin­gTimeout=function(a,b){var c=this;setTimeout(function(){c.sendStrin­g(a)},b)};exports.connect=function(a,b,c­,d){return new NRF(a,b,c,d)};\\n\");\n\nSPI1.setup({sck­:A5, miso:A6, mosi:A7});\nvar nrf = require(\"NRF24L01P\").connect(SPI1, B0, B1);\nfunction onInit() {\n  print(nrf);\n  if (typeof nrf != \"undefined\") {\n    nrf.init([0,0,0,0,1], [0,0,0,0,2]);\n    print(\"NRF Library loaded!\");\n  } else {\n    print(\"Error! NRF Library not loaded!\");\n  }\n}\nonInit();\nsetInterval(function() {\n    nrf.slaveHandler();\n}, 50);\necho(1);\n" espruino_serial.js:115
    >>> Sent espruino_status.js:40
    
  • in General
    Avatar for #kai

    Hi @Gordon!

    No, my internet connection is perfect reliable, i need it for work and other internet-centric hobbies.
    I claim to also understand what the WebIDE does and where it loads the modules from. So i also don't really see a reason for my issues. May it have something to do with the Javascript modules? On my first impression the minified version of the NRF24L01P module does differ from the non-minified one. Not only in the variable names, but i haven't had the time to check this in depth.

    Yes, that was the timing issue which i did encounter and will try that extra argument which you do suggest. With my hands on the boards back at home i will report back later...

  • in Interfacing
    Avatar for #kai

    Cool! I have one lying around here and will soon try your code out with it and hopefully find some time to give feedback here!

  • in General
    Avatar for #kai

    Sorry for that rubbish code blocks, the forum (if you want to call it like that) is a pain while formatting IMO

  • in General
    Avatar for #kai

    Hi Gordon,

    no I did paste the code to the right pane of the WebIDE. The following is what i am doing exactly...
    Left pane right after startup of the WebIDE and connecting to my Espruino board

     Connected
     =undefined
     >trace()
     #1[r1,l1] Object {
       #4[r1,l0] Name: '>timers'  #5[r2,l0] Array [
       ]
       #6[r1,l0] Name: '>watches'  #7[r2,l0] Array [
       ]
       #9[r1,l0] Name: '>history'  #10[r1,l0] Array [
         #11[r1,l0] Name: int 0  #8[r1,l0] String echo(0);
         #14[r1,l0] Name: int 1  #16[r1,l0] String console.log(\"<<\"+\"<<<\"+JSON.stringif­y(process.env)+\">>>\"+\">>\");
         #25[r1,l0] Name: int 2  #48[r1,l0] String echo(1);
       ]
       #13[r1,l0] Name: 'console'  #12[r1,l0] Function {
       }
       #15[r1,l0] Name: 'JSON'  #21[r1,l0] Function {
       }
       #24[r1,l0] Name: 'process'  #23[r1,l0] Function {
       }
     }  
     =undefined
     > 
    

    Right pane holds the slightly enhanced example code for the NRF24L01P module...

    SPI1.setup({sck:A5, miso:A6, mosi:A7});
    var nrf = require("NRF24L01P").connect(SPI1, B0, B1);
    
    function onInit() {
      print(nrf);
      if (typeof nrf != "undefined") {
        nrf.init([0,0,0,0,1], [0,0,0,0,2]);
        print("NRF Library loaded!");
      } else {
        print("Error! NRF Library not loaded!");
      }
    }
    onInit();
    setInterval(function() {
        nrf.slaveHandler();
    }, 50);
    

    After sending the code to the Espruino the following shows up in the left pane of the WebIDE:

    >reset();
    =undefined
       _____                 _ 
      |   __|___ ___ ___ _ _|_|___ ___ 
      |   __|_ -| . |  _| | | |   | . |
      |_____|___|  _|_| |___|_|_|_|___|
                |_|   http://www.espruino.com
      1v47 Copyright 2014 Gordon Williams
    ----------------------------------------­---
    >echo(0);
    ERROR: Function not found! Skipping. at line 1 col 32
    var nrf = require("NRF24L01P").connect(SPI1, B0, B1);
                                   ^
    undefined
    Error! NRF Library not loaded!
    =undefined
    ERROR: Using '.' operator on non-object at line 2 col 8
        nrf.slaveHandler();
           ^
    at line 2 col 21
        nrf.slaveHandler();
                        ^
    in function called from system
    ERROR: Using '.' operator on non-object at line 2 col 8
        nrf.slaveHandler();
           ^
    at line 2 col 21
        nrf.slaveHandler();
                        ^
    in function called from system
    ERROR: Using '.' operator on non-object at line 2 col 8
        nrf.slaveHandler();
           ^
    at line 2 col 21
        nrf.slaveHandler();
                        ^
    in function called from system
    ...
    >clearInterval();
    =undefined
    > 
    

    When copying the code for the module from teh Espruino website into the Editor (right pane of the WebIDE) my Espruino also has problems to interpret the Javascript code. Maybe i should use the minified versions to check if it works?
    Anyways, after clearing up all those inline '/..../' style comments the code did work last night, but i got some timing errors on the Espruino console (left pane in WebIDE). Maybe i can reproduce these again tomorrow if it helps.

  • in General
    Avatar for #kai

    Last night i was playing around with my just arrived and shiny new two Espruino boards. With the pack of two and included NRF24L01P wireless modules, I had the exact same issue when my code did try to load the NRF module as described on the corresponding Espruino page (http://www.espruino.com/NRF24L01P).

    Since Gordons last answer to this issue is 2 month old I would like to ask if we still have to install the Espruino WebIDE from GitHub for this issue to resolve?

    Is it easier to run the modules from an microSD card or would the WebIDE be the recommended start with Espruino? Previously I did use Espruino on my Olimex-STM32 and the WebIDE. But the 100% CPU bug contuinously forced me to do a complete restart of Chrome after some time. So currently the WebIE is not my real favorite way to go.

    P.S.: It is cool to finally have the real boards in my hands after following this project for all the time. Nice work and keep up that great project!

Actions