espruino / EspruinoTools

JavaScript library of tools for Espruino - used for the Web IDE, CLI, etc.
Apache License 2.0
150 stars 89 forks source link

Can't connect to port #97

Closed vforv closed 4 years ago

vforv commented 5 years ago

My command:

sudo espruino -p /dev/ttyUSB0
Espruino Command-line Tool 0.1.28
-----------------------------------

Connecting to '/dev/ttyUSB0'
Port "/dev/ttyUSB0" not found
Unable to connect!

I can list /dev/ttyUSB0 in directory and I can connect to port with chrome plugin. But not working with cli!

gfwilliams commented 5 years ago

Try running with --verbose and see what it says. Most likely there has been some kind of error installing the serialport package.

Which OS are you on, and which version of node?

vforv commented 5 years ago

Verbose return this error:

Connecting to '/dev/ttyUSB0' Noble: module couldn't be loaded, no node.js Bluetooth Low Energy { Error: Cannot find module 'noble' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15) at Function.Module._load (internal/modules/cjs/loader.js:529:25) at Module.require (internal/modules/cjs/loader.js:659:17) at require (internal/modules/cjs/helpers.js:22:18) at startNoble (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10), :51:15) at Object.getPorts (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10), :126:14) at eval (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10), :90:14) at Array.forEach () at getPorts (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10), :88:13) at openSerialInternal (eval at loadJS (/usr/local/lib/node_modules/espruino/index.js:10:10), :135:14) code: 'MODULE_NOT_FOUND' } No navigator.bluetooth - Web Bluetooth not enabled Port "/dev/ttyUSB0" not found - checking ports again (2 attempts left) Noble: getPorts - disabled Port "/dev/ttyUSB0" not found - checking ports again (1 attempts left) Noble: getPorts - disabled Port "/dev/ttyUSB0" not found Unable to connect! Done

POP OS, error ocure on ubuntu as well.

Node version: v11.4.0

gfwilliams commented 5 years ago

Anything else? Specifically we care about mentions of serialport.

Even if Noble isn't found (that error you see) it should still try and use serialport to get at USB ports.

aliustaoglu commented 5 years ago

Hi Gordon, I have the same problem. I am on macOS Mojave 10.14.5 and node 10.16.0.

> espruino-http-server@0.0.1 upload2 /Development/ESPRuino/projects/espruino-http-server
> espruino -p /dev/cu.wchusbserial1420 -b 115200 --board boards/ESP8266_4MB.json -e 'save()' index.js

Espruino Command-line Tool 0.1.28
-----------------------------------

Explicit board JSON supplied: "boards/ESP8266_4MB.json"
Connecting to '/dev/cu.wchusbserial1420'
Port "/dev/cu.wchusbserial1420" not found
Unable to connect!

I can list the port. It does exist.

$ ls /dev/cu.w*
/dev/cu.wchusbserial1420

I flash the firmware without a problem. I can use screen method and run commands inside it. No problem. But when I try to upload a file it fails.

And below is the verbose output:

> espruino-http-server@0.0.1 upload2 /Development/ESPRuino/projects/espruino-http-server
> espruino  --verbose -p /dev/cu.wchusbserial1420 -b 115200 --board boards/ESP8266_4MB.json -e 'save()' index.js

0.1.28
Espruino Command-line Tool 0.1.28
-----------------------------------

Acorn library not found - you'll need it for compiled code
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/libs/targz.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/libs/utf8.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/espruino.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/codeWriter.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/config.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/env.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/flasher.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/modules.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/notifications.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_chrome_serial.js
No chrome.serial - Chrome Serial disabled
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_chrome_socket.js
No chrome.sockets - Chrome Socket disabled
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_frame.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_noble.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_node_serial.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_node_socket.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_web_audio.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_web_bluetooth.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_websocket_local.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_websocket_relay.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/serial_winnus.js
Not on Windows, Winnus not needed
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/terminal.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/core/utils.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/assembler.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/boardJSON.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/compiler.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/getGitHub.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/localModules.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/minify.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/pretokenise.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/saveOnSend.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/setTime.js
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/unicode.js
Loading UTF8 with require
Found /Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/plugins/versionChecker.js
Initialising CodeWriter
Initialising Config
Initialising Env
Initialising Flasher
Initialising Modules
Initialising Notifications
Initialising Serial
  - Initialising Serial Noble Bluetooth LE
  - Initialising Serial Node Serial
  - Initialising Serial Node Socket
  - Initialising Serial Web Bluetooth
Initialising Utils
Initialising Status
Initialising Assembler
Initialising BoardJSON
Initialising Compiler
Initialising GetGitHub
Initialising LocalModules
Initialising Minify
Initialising Pretokenise
Initialising SaveOnSend
Initialising SetTime
Initialising Unicode
Initialising VersionChecker
Initialising CoreModules
Explicit board JSON supplied: "boards/ESP8266_4MB.json"
Manual board JSON load complete
Connecting to '/dev/cu.wchusbserial1420'
Noble: module couldn't be loaded, no node.js Bluetooth Low Energy
 { Error: Cannot find module 'noble'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at startNoble (eval at loadJS (/Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/index.js:10:10), <anonymous>:51:15)
    at Object.getPorts (eval at loadJS (/Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/index.js:10:10), <anonymous>:126:14)
    at eval (eval at loadJS (/Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/index.js:10:10), <anonymous>:90:14)
    at Array.forEach (<anonymous>)
    at getPorts (eval at loadJS (/Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/index.js:10:10), <anonymous>:88:13)
    at openSerialInternal (eval at loadJS (/Development/ESPRuino/projects/espruino-http-server/node_modules/espruino/index.js:10:10), <anonymous>:135:14) code: 'MODULE_NOT_FOUND' }
No navigator.bluetooth - Web Bluetooth not enabled
Port "/dev/cu.wchusbserial1420" not found - checking ports again (2 attempts left)
Noble: getPorts - disabled
Port "/dev/cu.wchusbserial1420" not found - checking ports again (1 attempts left)
Noble: getPorts - disabled
Port "/dev/cu.wchusbserial1420" not found
Unable to connect!
Done

Then I switched to node 8 nvm use v8.10.0. I also had to downgrade to espruino@0.1.12. Now it's working fine.

I can use node8 it's OK but do you know why this is not working for node 10 and node 11? 0.1.28 still fails with node8. Highest version I could use was espruino@0.1.20. 20+ versions all fail with either different error messages or cannot find port message.

Espruino Command-line Tool 0.1.12
-----------------------------------

Explicit board JSON supplied: "boards/ESP8266_4MB.json"
Connecting to '/dev/cu.wchusbserial1420'
Connected
--] 
--]  ____                 _ 
--] |  __|___ ___ ___ _ _|_|___ ___ 
--] |  __|_ -| . |  _| | | |   | . |
--] |____|___|  _|_| |___|_|_|_|___|
--]          |_| espruino.com
--]  1v99 (c) 2018 G.Williams
--] 
--] Espruino is Open Source. Our work is supported
--] only by sales of official boards and donations:
--] http://espruino.com/Donate
--] Flash map 4MB:512/512, manuf 0xc8 chip 0x4016
--] 
--] >
--] =undefined
--] Compacting Flash...
--] Calculating Size...
--] Writing..
gfwilliams commented 5 years ago

I'm not sure - as far as I can see from the log, the 'node serial' plugin installed just fine so it should have picked up the serial port even though bluetooth failed.

aliustaoglu commented 5 years ago

It's OK. I think the problem is with dependencies working not very stable with macOS. I now use a Docker image using the same port but it works fine from the container with the latest version. I documented the steps I followed so I won't forget in the future. Leaving it here just in case anyone wants some workaround.

https://cloud.docker.com/u/aliustaoglu/repository/docker/aliustaoglu/espruino