Avatar for Dennis

Dennis

Member since Feb 2015 • Last active Oct 2017
  • 13 conversations
  • 62 comments

Most recent activity

    • 19 comments
    • 14,596 views
  • in General
    Avatar for Dennis

    I will try it! By the way, I see you are communicating over a tty device. I noticed that on my Mac, the tool recognizes only the cu ports but not the corresponding tty ports. The cu ports work, but I cannot have another terminal program connected and reading at the same time because access is exclusive.

  • in General
    Avatar for Dennis

    Cool, thanks :)

    I suppose the reason is that the WebIDE and the command-line tool share common code but they use it in different ways, and when the WebIDE was improved, this common code was changed in a way that breaks only the command-line tool but works for the WebIDE.

  • in General
    Avatar for Dennis

    I fixed another bug (see github discussion with @Gordon about my changes) and now finally I'm talking to Espruino.

    But for some reason I'm not getting the correct return values and console output from Espruino.

    I have a file foo.js:

    a=123;
    console.log(a+1);
    

    Now when I call espruino tool, I get the following:

    $ espruinotool -p /dev/cu.usbmodem1411 foo.js
    espruino-tools
    --------------
    
    Connecting to '/dev/cu.usbmodem1411'
    --]___
    --]|   __|_ -| . |  _| | | |   | . |
    --]|_____|___|  _|_| |___||_|_|___|
    --]          |_| http://espruino.com
    --] 1v81 Copyright 2015 G.Williams
    --]
    --]>
    --]=undefined
    --]>
    --]
    Connected
    --]=undefined
    

    I expected it to return 123 for the first statement, then write 124 to the console and then return undefined for the second statement. The console output is nowhere to be found and undefined is not the correct result. But if I now use WebIDE, I can verify that a really has the value 123, so the code has been executed.

  • in General
    Avatar for Dennis

    @the1laz: Yes!!! This is exactly what I need!

    But it won't run :( After I fixed a few bugs in the code that caused it to crash, espruinotool now at least reports an error that the port was not found. I called espruinotool -p /dev/tty.usbmodem1411 foo.js, but for some reason no ports are found at all (getPorts returns an empty array).

  • in General
    Avatar for Dennis

    @allObjects: you have quite a few good ideas there. I like the idea of having a flexible build system that works tightly integrated with the IDE.

    The main reason why I don't want to use the IDE this time is that I want to code in CoffeeScript and I cannot do that in the IDE because its syntax highlighting is for JavaScript and the IDE also does not support pre-processing.

  • in General
    Avatar for Dennis

    @DrAzzy: Thank you! Aha, simple trick but works :) So it appears it's sending

    • echo(0);
    • Modules.removeAllCached();
    • Modules.addCached(<moduleName>, <moduleCode>) for every module, where moduleCode is the minified module as a string. This is recursive (i.e. includes modules required by modules).
    • The contents of the editor window
    • echo(1);

    Looking back with the up-arrow shows the code from the editor not in one chunk but in several chunks, where each function or each top-level line of code is one chunk... but it seems there's nothing special about sending code that way, it seems to be only related to retrieving code from the command history with the up-arrow. How do I know? Well, if I copy a js file to the espruino tty device, it's certainly sent in one chunk but yet it also appears as several chunks in the command history.

    So... how should I parse code for require? The easiest thing would be a regular expression just scanning for the word and what's between the brackets. However, that would also require a module when the require has been commented out. And the developer might do crazy things like moduleName="foo"; require(foo); which would need a semantical parser. I'm not sure how smart that parser should really be, but I guess it would be nice if it did the same that the WebIDE does...

  • in General
    Avatar for Dennis

    What exactly does the WebIDE do when the button "send to Espruino" is pressed? Especially, how does it handle

    • requires
    • compiled functions
    • minification
      and what does it send over the serial interface?

    The reason for my question is that I would like to use a task runner (such as grunt) to generate JavaScript from other stuff and deploy it to Espruino, since it would be bothersome to always copy and paste the result into the WebIDE. I basically need a command-line version of the send-to-Espruino button... what would it have to do?

  • in Interfacing
    Avatar for Dennis

    I missed a disconnect function when testing connect-on-demand code. I haven't got as far as saving power, but that will become a very important topic. On a battery operated device, I want the battery to last long, but I also want it to be ready quickly. After powering up, it takes a few seconds to initialize and then connect to an AP. I'm not sure if there's a power-efficient way to keep it on standby...

Actions