You are reading a single comment by @stephaneAG and its replies. Click here to read the full conversation.
  • a little update:

    I can now send stuff to Espruino from Ubuntu using:

     chrome.serial.write(str2ab("<some expression>;\r"), callback)
    

    and with a simple listener, I also get the callbacks ;D
    ( I'll try few stuff to have dynamic listeners to check for specific callbacks later ( .. ) )

    I currently use Gordon's implm of str2ab ( found in the 'serial_chrome.js' ) as it handle some chars stuff that the chrome examples implms doesn't, but gotta try the other just to know if it'd work ^^

    The issue is still not solved on os x 10.6.8 & I filed some stuff hoping to get a feedback ( among other forums, the issue may be close to this one: https://bugs.chromium.org/p/chromium/iss­ues/detail?id=448698 )

    +Gordon Nope, you're right: I want the minimum overhead possible, so just the bare minimum to send commands & send a file, and maybe later flash the board ( like in the Web IDE ).
    On this subject, am I the only one interested in getting the minimized code sent from the IDE to Espruino saved to an external file ? this 'd ease sending minimized/optimized files afterward without the need for the complete IDE to be installed/run

    As sending commands is almost done now, so I'm starting to digg how to replicate 'sendFile()' & 'flash()'
    My two contexts are the D&D of a file on the chrome app:

    var dnd = new DnDFileController('body', function(data) {
      var fileEntry = data.items[0].webkitGetAsEntry();
      displayPath(fileEntry); // display the fullpath to the entry
      // display the contents of the file
      fileEntry.file(function(file) {
        var reader = new FileReader();
        reader.onerror = errorHandler;
        reader.onloadend = function(e) {
          console.log(e.target.result);
          var theCode = "reset();\n" + "echo(0);\n" + e.target.result.replace(/\n/g, "\x1B\x0A") + "echo(1);\n" + "save();\r"; // code ready to be uploaded to the Espruino (nb: doesn't save any previous config nor update settings except those present in the file )
        };
    
        reader.readAsText(file);
      });
    });
    

    and getting one from the sandboxed fs:

    theFs.root.getFile('/Firmwares/fakeFirmw­are.js', {}, function(fileEntry) {
      fileEntry.file(function(file) {
        var reader = new FileReader();
        reader.onloadend = function(e) {
          console.log(this.result);
          var toUpload = "reset();\n" + "echo(0);\n" + this.result.replace(/\n/g, "\x1B\x0A") + "echo(1);\n" + "save();\r"; // code ready to be uploaded to the Espruino (nb: doesn't save any previous config nor update settings except those present in the file )
        };
        reader.readAsText(file);     
      }, errorHandler);
    }, errorHandler);
    

    For 'sendFile()', can I send everything at once using the above concatenated stuff or do I have to do it line by line / by chunks ( or "throttled" serial write ) ?
    ( for 'flash()', I guess I'll see later, but I feel it'd be a little more complex .. :p )
    Also, I based the above stuff from codeWriter.js

    // ..to tell Espruino it's a new line but not to execute ( as Alt+Enter or Ctrl+LF ): stuff.replace(/\n/g, "\x1B\x0A");
    

    Lastly, and this is the end of this post to keep it short, I noticed that the message I had in the Web IDE running on os x 10.6.8 comes from a call that resides in the serial.js file at line 147 ( https://github.com/espruino/EspruinoTool­s/blob/gh-pages/core/serial.js )

    console.error("Already sending data - calling callback immediately!");
    

    I was wondering why this fcn 'd be called in the context of the Espruino web IDE in its Chrome packaged app version, since calls should normally invoke functions declared in serial_chrome.js to use the chrome serial api ( as both are loaded in main.html, and as I didn't stumble upon the code that'd choose one or the other depending on some criterias ( line 66 of serial.js ? ) ).
    This may be totally normal, but I never saw this in the console of the IDE while on Ubuntu, so if this could lead to solving some issues, I can't afford not to ask :)

    looking forward to solving those & reading for yall ;p

About

Avatar for stephaneAG @stephaneAG started