New command-line tools

Posted on
  • Hi,

    Just thought I'd let you know that the espruinotool command-line tool is now available: https://github.com/espruino/espruino-tools

    You'll need node.js and npm installed before you can use it, but hopefully after that it should be pretty multi-platform. Installation instructions are at the link, and once installed it should be pretty easy to integrate it with your favourite editor.

    There are already two node.js-based tools out there ( espruino-cli and node-espruino), but this one uses exactly the same code as the Web IDE - so will handle everything that the Web IDE does.

  • This will come in handy :) thanks!

  • Yes, this will be useful. Especially since Chromium/Chrome causes my X-windows to crash.

  • Sweet! Will test come monday.

  • Added support for multi-board upload. Might be handy for more people than me https://github.com/espruino/espruino-tools/pull/1

    Excellent tool btw!

  • Thanks! Will try and take a look tomorrow.

    By the way, on Linux you can do some great stuff with udev so you can run a script (like this) whenever a certain type of USB device is plugged in. It'd be great for deployment.

    Extra thing I guess I should add is firmware updates.

  • I tried to add firmware updates using Espruino.Core.Flasher.flashDevice(url, callback) but could not manage to get it working during my 5minutes break. It sure would be a nice feature, but for now I'm happy with make serialflash

    EDIT: I need to investigate that udev thingy, will be handy when deploying to ~40 espruinos in a month or two

  • I could be wrong (may need some fiddling) but the udev rule should look something like this:

    # Standard Espruino udev rule
    ATTRS{idProduct}=="5740", ATTRS{idVendor}=="0483", ENV{ID_MM_DEVICE_IGNORE}="1", MODE="0666", GROUP="plugdev"
    
    # Run stuff when it's plugged in
    ACTION=="add",SUBSYSTEM=="tty",SUBSYSTEMS=="usb",ATTRS{idVendor}=="0483",ATTRS{idProduct}=="5740",RUN+="/home/your/script.sh /dev/%k"
    
  • Just had a play with the flasher (have updated the code). I can get it to erase the device, but something is broken when it tries to write data to it.

    There were some issues with conversion between datatypes that I had to fix in EspruinoTools (String/ArrayBuffer/Buffer), and I wonder if there are still some problems there.

  • Can this module be used from inside node? Like in a js file with require like with node-espruino?

  • I'm not sure it can be at the moment - but if anyone wanted to make that happen I'd love to include it. It'd definitely make integration with other node.js software a whole lot easier.

  • Excellent. Atom plugin in 3...2...1

  • I am trying to run the command tool under Linux Mint but no dice! please note the WebIDE works great, can has anyone had success running the command line under Linux and can they help me, thanks:


    1 Attachment

    • commandLineError1.png
  • Can you run espruino --list and see what it says? Also espruino --verbose?

    Its possible that the node-serialport NPM library hasn't got installed for some reason, so the CLI has no way to find devices.

    I use Mint for everything here so I know it works :)

  • Hi Gordon, thanks for getting back to me, list below is a screen shot and the text from the commands you asked me to try:

    a1kerr@a1kerr-Presario-CQ61-Notebook-PC ~ $ espruino --verbose
    0.0.34

    Espruino Command-line Tool 0.0.34

    Acorn library not found - you'll need it for compiled code
    Found /usr/local/lib/node_modules/espruino/libs/targz.js
    Found /usr/local/lib/node_modules/espruino/libs/utf8.js
    Found /usr/local/lib/node_modules/espruino/espruino.js
    Found /usr/local/lib/node_modules/espruino/core/codeWriter.js
    Found /usr/local/lib/node_modules/espruino/core/config.js
    Found /usr/local/lib/node_modules/espruino/core/env.js
    Found /usr/local/lib/node_modules/espruino/core/flasher.js
    Found /usr/local/lib/node_modules/espruino/core/modules.js
    Found /usr/local/lib/node_modules/espruino/core/notifications.js
    Found /usr/local/lib/node_modules/espruino/core/serial.js
    Found /usr/local/lib/node_modules/espruino/core/serial_audio.js
    Found /usr/local/lib/node_modules/espruino/core/serial_chrome.js
    Found /usr/local/lib/node_modules/espruino/core/serial_noble.js
    'noble' module couldn't be loaded, no node.js Bluetooth Low Energy
    { Error: Cannot find module 'bluetooth-hci-socket'

    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/espruino/node_modules/noble/lib/hci-socket/hci.js:6:26)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3) code: 'MODULE_NOT_FOUND' }
    

    Found /usr/local/lib/node_modules/espruino/core/serial_nodeserial.js
    No 'serialport' module found
    Found /usr/local/lib/node_modules/espruino/core/serial_socket.js
    No chrome.sockets - serial_socket disabled
    Found /usr/local/lib/node_modules/espruino/core/serial_web_bluetooth.js
    Found /usr/local/lib/node_modules/espruino/core/serial_websocket.js
    Found /usr/local/lib/node_modules/espruino/core/serial_winnus.js
    'winnus' module not found, no Windows Bluetooth Low Energy { Error: Cannot find module 'winnus'

    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at eval (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:5:14)
    at eval (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:126:3)
    at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10)
    at loadDir (/usr/local/lib/node_modules/espruino/index.js:20:7)
    at Object.init (/usr/local/lib/node_modules/espruino/index.js:93:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/espruino/bin/espruino-cli.js:574:24) code: 'MODULE_NOT_FOUND' }
    

    Found /usr/local/lib/node_modules/espruino/core/terminal.js
    Found /usr/local/lib/node_modules/espruino/core/utils.js
    Found /usr/local/lib/node_modules/espruino/plugins/assembler.js
    Found /usr/local/lib/node_modules/espruino/plugins/boardJSON.js
    Found /usr/local/lib/node_modules/espruino/plugins/compiler.js
    Found /usr/local/lib/node_modules/espruino/plugins/getGitHub.js
    Found /usr/local/lib/node_modules/espruino/plugins/localModules.js
    Found /usr/local/lib/node_modules/espruino/plugins/minify.js
    Found /usr/local/lib/node_modules/espruino/plugins/saveOnSend.js
    Found /usr/local/lib/node_modules/espruino/plugins/setTime.js
    Found /usr/local/lib/node_modules/espruino/plugins/unicode.js
    Found /usr/local/lib/node_modules/espruino/plugins/versionChecker.js
    Initialising CodeWriter
    Initialising Config
    Initialising Env
    Initialising Flasher
    Initialising Modules
    Initialising Notifications
    Initialising Serial

    • Initialising Serial Web Bluetooth
      Initialising Utils
      Initialising Status
      Initialising Assembler
      Initialising BoardJSON
      Initialising Compiler
      Initialising GetGitHub
      Initialising LocalModules
      Initialising Minify
      Initialising SaveOnSend
      Initialising SetTime
      Initialising Unicode
      Initialising VersionChecker
      Searching for serial ports...
      No navigator.bluetooth - Web Bluetooth not enabled
      PORTS:

    /usr/local/lib/node_modules/espruino/bin/espruino-cli.js:567

          throw new Error("No Ports Found");
          ^
    

    Error: No Ports Found

    at /usr/local/lib/node_modules/espruino/bin/espruino-cli.js:567:17
    at eval (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:69:11)
    at Object.getPorts (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:92:7)
    at eval (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:52:14)
    at Array.forEach (native)
    at Object.getPorts (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:15), <anonymous>:51:13)
    at /usr/local/lib/node_modules/espruino/bin/espruino-cli.js:544:28
    at setupConfig (/usr/local/lib/node_modules/espruino/bin/espruino-cli.js:231:9)
    at main (/usr/local/lib/node_modules/espruino/bin/espruino-cli.js:533:3)
    at Object.init (/usr/local/lib/node_modules/espruino/index.js:112:3)
    

    a1kerr@a1kerr-Presario-CQ61-Notebook-PC ~ $ ^C


    1 Attachment

    • espruino_List.png
  • It says:

    Found /usr/local/lib/node_modules/espruino/corĀ­e/serial_nodeserial.js
    No 'serialport' module found
    

    So that means that the serialport NPM module (https://www.npmjs.com/package/serialport) hasn't installed. Perhaps just try sudo npm install -g serialport first, and try and get that working (if it fails, which I guess it will, there should be a bunch of info online).

    Maybe try: https://www.npmjs.com/package/serialport#ubuntudebian-linux

    Then once that's done, reinstall the CLI tools and hopefully they should drag in the serialport module this time and it'll all work great.

  • I will give it a go, please I did try to install the serial port module and no dice! I will hunt to around to see why that is and get back to you, thanks again.

  • Gordon good news, gots it working, thanks bro:
    *** history dump on how I was able to get the command line working
    #check to see what is installed, looking to remove nodejs if installed
    792 dpkg --list
    793 sudo apt-get --purge remove nodejs

    #checking to make sure nodejs was uninstalled, now looking to remove espruino
    794 dpkg --list
    795 sudo apt-get purge --auto-remove espruino

    #clean up and left over packages and junk, then check list to make sure no nodejs and espruino installed.
    797 sudo apt-get autoremove
    798 sudo apt-get clean
    799 dpgk --list

    #reinstall nodejs using Ubuntu and Node 6
    811 curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
    812 sudo apt-get install -y nodejs
    813 sudo apt-get update
    814 sudo apt-get upgrade

    #libudev-dev some package I thought I needed but not sure is mandatory, I think the main thing is to install the build-essential to allow install to compile anything needed.
    818 sudo apt-get install libudev-dev
    822 sudo apt-get install build-essential

    #install serial port manually in unsafe mode, this may have not been need but did want to take a chance so I through the kitchen sink at it :)
    823 sudo npm install serialport --unsafe-perm --build-from-source

    #And not for the main event reinstalling espruino! then run some quick test and connect.
    825 sudo npm install -g espruino
    826 espruino --list
    830 espruino --verbose
    831 espruino -p /dev/ttyUSB0 -b 115200

    #THANKS AGAIN GORDON AND PEACE OUT!


    a1kerr@a1kerr-Presario-CQ61-Notebook-PC ~ $ espruino --verbose
    0.0.34

    Espruino Command-line Tool 0.0.34

    Acorn library not found - you'll need it for compiled code
    Found /usr/lib/node_modules/espruino/libs/targz.js
    Found /usr/lib/node_modules/espruino/libs/utf8.js
    Found /usr/lib/node_modules/espruino/espruino.js
    Found /usr/lib/node_modules/espruino/core/codeWriter.js
    Found /usr/lib/node_modules/espruino/core/config.js
    Found /usr/lib/node_modules/espruino/core/env.js
    Found /usr/lib/node_modules/espruino/core/flasher.js
    Found /usr/lib/node_modules/espruino/core/modules.js
    Found /usr/lib/node_modules/espruino/core/notifications.js
    Found /usr/lib/node_modules/espruino/core/serial.js
    Found /usr/lib/node_modules/espruino/core/serial_audio.js
    Found /usr/lib/node_modules/espruino/core/serial_chrome.js
    Found /usr/lib/node_modules/espruino/core/serial_noble.js
    Found /usr/lib/node_modules/espruino/core/serial_nodeserial.js
    Found /usr/lib/node_modules/espruino/core/serial_socket.js
    No chrome.sockets - serial_socket disabled
    Found /usr/lib/node_modules/espruino/core/serial_web_bluetooth.js
    Found /usr/lib/node_modules/espruino/core/serial_websocket.js
    Found /usr/lib/node_modules/espruino/core/serial_winnus.js
    'winnus' module not found, no Windows Bluetooth Low Energy { Error: Cannot find module 'winnus'

    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at eval (eval at loadJS (/usr/lib/node_modules/espruino/index.js:10:10), <anonymous>:5:14)
    at eval (eval at loadJS (/usr/lib/node_modules/espruino/index.js:10:10), <anonymous>:126:3)
    at loadJS (/usr/lib/node_modules/espruino/index.js:10:10)
    at loadDir (/usr/lib/node_modules/espruino/index.js:20:7)
    at Object.init (/usr/lib/node_modules/espruino/index.js:93:3)
    at Object.<anonymous> (/usr/lib/node_modules/espruino/bin/espruino-cli.js:574:24) code: 'MODULE_NOT_FOUND' }
    

    Found /usr/lib/node_modules/espruino/core/terminal.js
    Found /usr/lib/node_modules/espruino/core/utils.js
    Found /usr/lib/node_modules/espruino/plugins/assembler.js
    Found /usr/lib/node_modules/espruino/plugins/boardJSON.js
    Found /usr/lib/node_modules/espruino/plugins/compiler.js
    Found /usr/lib/node_modules/espruino/plugins/getGitHub.js
    Found /usr/lib/node_modules/espruino/plugins/localModules.js
    Found /usr/lib/node_modules/espruino/plugins/minify.js
    Found /usr/lib/node_modules/espruino/plugins/saveOnSend.js
    Found /usr/lib/node_modules/espruino/plugins/setTime.js
    Found /usr/lib/node_modules/espruino/plugins/unicode.js
    Found /usr/lib/node_modules/espruino/plugins/versionChecker.js
    Initialising CodeWriter
    Initialising Config
    Initialising Env
    Initialising Flasher
    Initialising Modules
    Initialising Notifications
    Initialising Serial

    • Initialising Serial Noble
    • Initialising Serial Node Serial
    • Initialising Serial Web Bluetooth
      Initialising Utils
      Initialising Status
      Initialising Assembler
      Initialising BoardJSON
      Initialising Compiler
      Initialising GetGitHub
      Initialising LocalModules
      Initialising Minify
      Initialising SaveOnSend
      Initialising SetTime
      Initialising Unicode
      Initialising VersionChecker
      Searching for serial ports...
      No navigator.bluetooth - Web Bluetooth not enabled
      PORTS:
      /dev/ttyUSB0 (FTDI)
      /dev/ttyS0
      /dev/ttyS10
      /dev/ttyS11
      /dev/ttyS12
      /dev/ttyS13
      /dev/ttyS14
      /dev/ttyS15
      /dev/ttyS16
      /dev/ttyS17
      /dev/ttyS18
      /dev/ttyS19
      /dev/ttyS2
      /dev/ttyS20
      /dev/ttyS21
      /dev/ttyS22
      /dev/ttyS1
      /dev/ttyS24
      /dev/ttyS25
      /dev/ttyS26
      /dev/ttyS27
      /dev/ttyS28
      /dev/ttyS29
      /dev/ttyS3
      /dev/ttyS30
      /dev/ttyS31
      /dev/ttyS4
      /dev/ttyS5
      /dev/ttyS6
      /dev/ttyS7
      /dev/ttyS8
      /dev/ttyS9
      /dev/ttyS23
      Using first port, {"path":"/dev/ttyUSB0","usb":[1027,24577],"description":"FTDI"}
      Connecting to '/dev/ttyUSB0'
      Connected Ok
      Got ""
      No Prompt found, got undefined - issuing Ctrl-C to try and break out
      Splitting at "\u0003", delay 250
      Sending...
      ---> "\u0010console.log(\"<\",\"<<\",JSON.stringify(process.env),\">>\",\">\")\n"
      Sent
      No result found - just got ""
      Connected
  • Great - glad you got it sorted!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

New command-line tools

Posted by Avatar for Gordon @Gordon

Actions