You are reading a single comment by @jgw and its replies. Click here to read the full conversation.
  • Hello again,
    I ran into another difference while using Web IDE vs Espruino Tools. My programming flow for Bangle.js 2 bracelets involves building a single 'output file' for later download to multiple bracelets. It is mentioned on https://github.com/espruino/EspruinoTool­s that programming is as simple as :

    This file can then be sent directly to Espruino at some later time - sometimes just cat file.js > /dev/ttyACM0 is enough.

    Unfortunately I ran into an issue with 'special character strings'. Consider the following code (this the double arrow image used in Bangle's menu) :

    g.clear().drawImage("\x0c\x05\x81\x00 \x07\x00\xF9\xF0\x0E\x00@", 10, 10, {scale:4});
    

    This is prepared for download with :

    espruino --board BANGLEJS2 --config MINIFICATION_LEVEL=ESPRIMA --config SAVE_ON_SEND=1 /tmp/test.js -o /tmp/testOut.js
    

    'testOut.js' looks like :

    setTime(1634026260.035);E.setTimeZone(-7­)
    require("Storage").write(".bootcde","g.c­lear().drawImage('\\f\\x05\\x81\\0 \\x07\\0ùð\\x0E\\0@',10,10,{scale:4})",0­,67);
    load()
    

    When downloading this to the bracelet, the error 'Too much data for file size' is returned. After some tracing it turns out the download is 69 byte, not 67 (attached image). The image on the bracelet is - obviously - 'mangled'. A dump() looks messed up :

    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v10.89 (c) 2021 G.Williams
    >
    >
    >dump()
    // Code saved with E.setBootCode
    g.clear().drawImage('\f\x05\x81\0 \x07\0 extends in extends throw\x0E\0@',10,10,{scale:4})=undefined­
    > 
    

    Using the Web IDE and 'Send to Espruino' Flash, the file downloads OK and is 67 byte in size (attached). The dump () :

    >
    >dump()
    // Code saved with E.setBootCode
    g.clear().drawImage('\f\x05\x81\0 \x07\0 ?[249] ?[240]\x0E\0@',10,10,{scale:4})=undefine­d
    > 
    

    The difference are the codes for the 'ùð' characters. The strange thing is that the console dumps in Web IDE (development tools) show the same characters in the 'Sending' prompt, but result in a correct file being stored.

    >>> Sending...
    settingsConsole.js:30 ---> "\u0010reset();\n\u0010print()\n\u0010re­quire(\"Storage\").write(\".bootcde\",\"­g.clear().drawImage('\\\\f\\\\x05\\\\x81­\\\\0 \\\\x07\\\\0ùð\\\\x0E\\\\0@',10,10,{scal­e:4})\",0,67);\n\u0010load()\n\n"
    

    So obviously 'someone' is altering the output of the minified source before sending it down BLE. How then is it possible to just 'cat' an output file to a bracelet ? What are the additional modifications a minified source needs before 'just copying' to a Bangle.js 2 ?


    2 Attachments

    • webide.png
    • file.png
About

Avatar for jgw @jgw started