Giter Club home page Giter Club logo

Comments (5)

gfwilliams avatar gfwilliams commented on September 17, 2024

By default it should upload to RAM, so the code will be executed automatically. Why do you think it's not being run?

from espruinotools.

ktrzeciaknubisa avatar ktrzeciaknubisa commented on September 17, 2024

I think I experience the same issue - the script seems to be uploaded successfully, but it does not execute.
I am trying to run the LED1 blink sample

var  on = false;
setInterval(function() {
  on = !on;
  LED1.write(on);
}, 500);

and it does work when uploaded via Espruino IDE (Native) (the led is blinking).
(side note: the browser version cannot connect via Web Serial connection)

Then I try to do the same with espruino tools or with espruino npm module, and despite I see no error, the led is not blinking.

Espruino tools:

C:\>espruino -p COM3 --board ESP32 "C:\blinkLed1.js"
Espruino Command-line Tool 0.1.55
-----------------------------------

Explicit board JSON supplied: "ESP32"
Connecting to 'COM3'
Connected
Upload Complete

C:\Prv\Espruino\EspruinoTools>

Espruino NPM Module

The js code is pretty much as the one used by @msaigla
The output is way larger, but this is the tail of it:

Already initialised.
Noble: getPorts - disabled
Connected Ok
Got ""
No Prompt found, got undefined - issuing Ctrl-C to try and break out
Splitting for Ctrl-C, delay 250
Still no prompt - issuing another Ctrl-C
Splitting for Ctrl-C, delay 250
Sending...
---> "\u0010print(\"<\",\"<<\",JSON.stringify(process.env),\">>\",\">\")\n"
Sent
Receiving...
No result found for "process.env" - just got ""

Unable to retrieve board information.
Connection Error?
Minifying
Minification complete
Got ""
No Prompt found, got undefined - issuing Ctrl-C to try and break out
Splitting for Ctrl-C, delay 250
Still no prompt - issuing another Ctrl-C
Splitting for Ctrl-C, delay 250
Sending...
---> "\u0010reset();\n\u0010print()\n\u0010setTime(1714853595.315);E.setTimeZone(2)\n\u0010var  on = false;\n\u0010setInterval(function() {\u001b\n  on = !on;\u001b\n  LED1.write(on);\u001b\n}, 500);\n\n"
Splitting for reset(), delay 250
Sent
Done!

My environment

Windows 10

C:\>node --version
v16.15.0
C:\>npm --version
8.8.0

BTW. Which version of node/npm is know to be best compatible?
I got some vulnerabilities errors / warnings when running npm i espruino

C:\Prv\Espruino\ET>npm i espruino
npm WARN deprecated [email protected]: Use your platform's native DOMException instead

added 70 packages, and audited 71 packages in 22s

5 vulnerabilities (1 moderate, 4 high)

from espruinotools.

ktrzeciaknubisa avatar ktrzeciaknubisa commented on September 17, 2024

I should also probably add that -e does not work as well:

C:\>espruino -p COM3 --board ESP32 -e "digitalWrite(LED1,1)"
Espruino Command-line Tool 0.1.55
-----------------------------------

Explicit board JSON supplied: "ESP32"
Connecting to 'COM3'
Connected
Upload Complete

but again, it does work when uploaded via Espruino IDE (Native) (the led is ON).

from espruinotools.

ktrzeciaknubisa avatar ktrzeciaknubisa commented on September 17, 2024

Many hours later... I think I found a workaround.

Few factors are required (if I omit at least one of them, those steps won't succeed):

  1. I needed to add -b 115200 explicitly
  2. run espruino tools command 2 times
  3. press a hardware RESET on Arduino board between the uploads

Those are the steps:

1. Upload first time

c:\>espruino c:\blinkLed1.js --board ESP32 -p COM3 -b 115200
Espruino Command-line Tool 0.1.55
-----------------------------------

Explicit board JSON supplied: "ESP32"
Connecting to 'COM3'
Connected
Upload Complete

At this point nothing happpened just yet (the script did not run - Led is not blinking)

2. Press hardware RESET button (on my ESP32 this is EN button)

3, Upload second time - with the very exact command

c:\>espruino c:\blinkLed1.js --board ESP32 -p COM3 -b 115200
Espruino Command-line Tool 0.1.55
-----------------------------------

Explicit board JSON supplied: "ESP32"
Connecting to 'COM3'
Connected
--]
--]  ____                 _
--] |  __|___ ___ ___ _ _|_|___ ___
--] |  __|_ -| . |  _| | | |   | . |
--] |____|___|  _|_| |___|_|_|_|___|
--]          |_| espruino.com
--]  2v21 (c) 2023 G.Williams
--]
--] Espruino is Open Source. Our work is supported
--] only by sales of official boards and donations:
--] http://espruino.com/Donate
--]
--] >
Upload Complete

Note, that the otuput differs now (Espruino logo is shown)
and also, the LED is blinking!

4. Change the program and reupload - from now on it will work

From now on, I can change the blinkLed1.js file, then upload with the very same command from above and the new code will execute just fine!

from espruinotools.

gfwilliams avatar gfwilliams commented on September 17, 2024

Glad you got it sorted!

I think as you found the main issue is the baud rate. It's probably why Web Serial didn't work for you either (there's a setting in the Web IDE that you can set).

The reason is that official Espruino boards use 9600 baud, but the folks working on the ESP8266/32 ports decided not to do the same and to use 115200 instead - so now all ESP32 users have to remember to change baud rate each time.

Probably the second run of the tools was needed because when running without the baud rate set, some corrupt data would have been sent to the board, and that needed 'flushing out' before the upload would work,

from espruinotools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.