Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Failed to open serial port /dev/ttyUSB0 due to error: + TypeError: Cannot read property 'close' of null #774

Closed
meier99 opened this issue Feb 14, 2019 · 47 comments
Assignees

Comments

@meier99
Copy link

meier99 commented Feb 14, 2019

Issue Type: Bug

Always happens on 'Arduino: Open Serial Monitor'.

Upload of sketch (Arduino: Upload) to board via /dev/ttyUSB0 works.
Serial Monitor started via Arduino application also works fine.

Extension version: 0.2.25
VS Code version: Code 1.31.0 (7c66f58312b48ed8ca4e387ebd9ffe9605332caa, 2019-02-05T22:32:48.719Z)
OS version: Linux ia32 4.15.0-45-generic

System Info
Item Value
CPUs Intel(R) Core(TM) i3-2330M CPU @ 2.20GHz (4 x 1167)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
surface_synchronization: enabled_on
video_decode: unavailable_off
webgl: enabled
webgl2: enabled
Load (avg) 0, 0, 0
Memory (System) 3.89GB (0.60GB free)
Process Argv --unity-launch
Screen Reader no
VM 0%
@czgtest
Copy link
Contributor

czgtest commented Feb 19, 2019

I will investigate with it.

@stale
Copy link

stale bot commented Apr 16, 2019

This issue has been automatically marked as stale and closed because it has not had recent activity. Please feel free to open a new issue if you would like further discussion. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2019
@edalongeville
Copy link

edalongeville commented Apr 22, 2019

Hello,

I am facing the same problem on Manjaro 18, running extension version 0.2.25, VSCode 1.33.1 and arduino 1.8.9.

"Arduino: Upload" works perfectly, but opening the serial port causes the following error:

Failed to open serial port /dev/ttyUSB0 due to error: + TypeError: Cannot read property 'close' of null

This is not a permission issue. I put my ttyUSB0 ad chmod 777 to troubleshoot, the problem is still here.
Using the same software versions, it works on my Ubuntu 18.04 Laptop.

Here's what the developer tools gave me:

console.ts:134 [Extension Host] [Warn] no library available after trying files (16) ["/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…ative/lib/native/usb-native_darwin_1.4.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…ative/lib/native/usb-native_darwin_1.6.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…ative/lib/native/usb-native_darwin_1.7.3_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…ative/lib/native/usb-native_darwin_2.0.2_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…tive/lib/native/usb-native_darwin_3.0.10_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…/lib/native/usb-native_Ubuntu14.04_1.4.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…/lib/native/usb-native_Ubuntu14.04_1.6.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…/lib/native/usb-native_Ubuntu14.04_1.7.3_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…/lib/native/usb-native_Ubuntu14.04_2.0.2_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…lib/native/usb-native_Ubuntu14.04_3.0.10_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…native/lib/native/usb-native_win32_1.4.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…native/lib/native/usb-native_win32_1.4.7_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…native/lib/native/usb-native_win32_1.6.6_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…native/lib/native/usb-native_win32_1.7.3_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…native/lib/native/usb-native_win32_2.0.2_x64.node", "/home/eric/.vscode-oss/extensions/vsciot-vscode.vs…ative/lib/native/usb-native_win32_3.0.10_x64.node"]
console.ts:134 [Extension Host] ApplicationInsights:Sender [{…}]
t.log @ console.ts:134
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:399
_invokeHandler @ rpcProtocol.ts:384
_receiveRequest @ rpcProtocol.ts:304
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:584
a @ ipc.net.ts:392
e @ ipc.net.ts:399
fire @ event.ts:584
_receiveMessage @ ipc.net.ts:678
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:549
fire @ event.ts:584
acceptChunk @ ipc.net.ts:212
_register._socket.onData.e @ ipc.net.ts:173
t @ ipc.net.ts:24
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94

The non-abreviated path is:

"/home/eric/.vscode-oss/extensions/vsciot-vscode.vscode-arduino-0.2.25/vendor/node-usb-native/lib/native/"

@stale stale bot removed the stale label Apr 22, 2019
@pg1992
Copy link

pg1992 commented Apr 28, 2019

I'm having the same issue. When I try to run F1 Arduino: Open Serial Monitor I get the warning

Failed to open serial port /dev/ttyUSB0 due to error: + TypeError: Cannot read property 'close' of null

Verify and upload run without any problems, and I can access the serial port running screen /dev/ttyUSB0 115200 on my terminal emulator.

If I run my project with code --verbose I get this in the output:

...
[17693:0428/103656.112433:INFO:CONSOLE(3214)] "[[object Object]]Cannot read property 'settings' of null", source: file:///usr/lib/code/out/vs/workbench/workbench.main.js (3214)
[17693:0428/103656.112481:INFO:CONSOLE(3214)] "TypeError: Cannot read property 'settings' of null
	at SerialMonitor.initialize (/home/espectro/.vscode-oss/extensions/vsciot-vscode.vscode-arduino-0.2.25/out/src/serialmonitor/serialMonitor.js:42:69)
	at constructor.dc.onDidChange (/home/espectro/.vscode-oss/extensions/vsciot-vscode.vscode-arduino-0.2.25/out/src/serialmonitor/serialMonitor.js:26:26)
	at u.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44:708)
	at loadContext.vscode.workspace.findFiles.then (/home/espectro/.vscode-oss/extensions/vsciot-vscode.vscode-arduino-0.2.25/out/src/deviceContext.js:76:39)", source: file:///usr/lib/code/out/vs/workbench/workbench.main.js (3214)
...

I'm running it on

@hywhuangyuwei
Copy link

I have this problem too.
I am using Manjaro with Arduino IDE 1.8.9 and Verify & Upload also works perfectly.
Note: I noticed that when I click the select serial port there is no response and I had to write that to the arduino.json manually.

@Moonlight63
Copy link

@hywhuangyuwei Same problem here with no response clicking select serial port. In my case, uploading from arduino also did not work. I had to use sudo chmod a+rw /dev/ttyACM0 to upload anything.

@aboulfad
Copy link

aboulfad commented Jul 3, 2019

Me too, just happened after VSCode updated itself to the latest June 2019 version ... I just reverted to May 2019, and the problem went away. It's clear something was broken in June 2019 version regarding this issue!

@dbaeumer
Copy link
Member

dbaeumer commented Jul 4, 2019

Regarding @aboulfad comment above: See this comment here for why this fails right now: microsoft/vscode#76538 (comment)

@ArthurMa1978
Copy link
Member

Fixed since Arduino extension v0.2.27, thanks @meier99 @edalongeville @pg1992 @hywhuangyuwei @Moonlight63 @aboulfad @dbaeumer .

@edalongeville
Copy link

Thanks a lot @ArthurMa1978 !

@DoganM95
Copy link

DoganM95 commented Sep 24, 2019

the above error "Failed to open serial port COM3 due to error: + TypeError: Cannot read property 'close' of null" still persists for me.

VSCode Version: 1.39.0 (insiders)
Arduino Extension Version: 0.2.27

Serial Monitor of Adruino IDE shows everything correctly, so this is definitely a vscode-arduino problem.

@AdrienTD
Copy link

I seem to now get this issue too after updating to the latest version of VSCode (v1.40.0). I can still compile and upload programs to my ESP32, but can't open the serial monitor anymore. Before the update I never had this problem. Opening the serial monitor still works in the Arduino IDE fortunately.

@janperner-ubnt
Copy link

janperner-ubnt commented Nov 10, 2019

Exactly the same issue here. It has stopped working after an upgrade to v1.40.0. minicom works properly.

@bukodi
Copy link

bukodi commented Nov 10, 2019

#MeToo :)

After upgrade VSCode to v1.40.0, serial monitor causes "TypeError: Cannot read property 'close' of null" (Ubuntu 18.04.3 LTS)

@bluesnotes
Copy link

Me too
VSCODE 1.40.0
Arduino extension version 0.2.27
Arduino 1.8.10

since upgrade VSCode to 1.40.0

@rnd-ash
Copy link

rnd-ash commented Nov 11, 2019

Me too since upgrading to vscode 1.4.0

@luke-shields
Copy link

Same issue here, also not able to select serial port as option

@serioushare
Copy link

Got the same issue, but I'm mostly using the arduino devtools serial monitor since it's 2 way.

@luke-shields: You can select the port by adding "port": "COM3", to the projects arduino.json file.

@xdubx
Copy link

xdubx commented Nov 13, 2019

Same issue on vsc 1.4.0 on linux. Serial port selecting with a waring in verbose mode. But no error message.
Flashing works, if you set the port manually.

@PeterWone
Copy link
Contributor

PeterWone commented Nov 13, 2019

The problem is well understood and has a straightforward solution. Enumeration of serial hardware depends on native node modules which breaks whenever the node version of VS Code changes. The historical solution has been to update the extension to use the new version of node, but this just breaks again later for the same reason – which is why this issue just won't die.

A permanent solution suggested by the VS Code team is to rewrite the unsupported code to use N-API, which is what they're adopting (VS Code also needs to call native modules).

If you want a fix immediately, revert to 1.39.2 and disable updates. Although there may be a node update it is more worthwhile to fix the problem properly and this will take a fair amount of work.

See also #918

@dooriya
Copy link
Member

dooriya commented Nov 15, 2019

The serial port issue has been fixed in the latest Arduino extension release (0.2.28).
Please install the latest Arduino 0.2.28 from marketplace https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino to verify if this is resolved on your environment.

@bluesnotes
Copy link

bluesnotes commented Nov 15, 2019 via email

@0xStarcat
Copy link

I just installed 0.2.28 and I still have the issue on linux. (arduino 2:1.0.5)

@PeterWone
Copy link
Contributor

PeterWone commented Dec 2, 2019

@0xStarcat

  • What version of VS Code do you have?
  • What distro and build of Linux?

I won't insult your intelligence by asking whether you've tried rebooting. You shouldn't need to. But if you haven't, now would be a good time to rule out orphaned locks or hung processes as contributing factors.

@dooriya dooriya assigned hellyzh and unassigned czgtest Dec 2, 2019
@0xStarcat
Copy link

@0xStarcat

  • What version of VS Code do you have?
  • What distro and build of Linux?

I won't insult your intelligence by asking whether you've tried rebooting. You shouldn't need to. But if you haven't, now would be a good time to rule out orphaned locks or hung processes as contributing factors.

Sorry for late reply. I can't provide more information because I don't remember what I was doing to cause it (doh!). Consider it resolved for me.

@DoganM95
Copy link

It has been a year, since this issue was opened and is still unsolved.
Any progress so far on this problem? This issue really renders the vscode-arduino extension useless.

@hellyzh
Copy link
Contributor

hellyzh commented Feb 28, 2020

@DoganM95 , I believe the issue has been fixed in the latest version. If you still has issue, please check your OS configuration, if you use linux, please check USB config according to Guid :
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>

@DoganM95
Copy link

DoganM95 commented Mar 5, 2020

@hellyzh

image

Extension Version: 0.2.29
VSCode (Insiders) Version: 1.43.0 (system)
OS: Windows 10 (Clean installation a couple days ago)

@hellyzh
Copy link
Contributor

hellyzh commented Mar 6, 2020

@DoganM95 , I created a new issue #980 to track this.
Please try to downgrade to VSCode 1.42 to work-around.

@DoganM95
Copy link

DoganM95 commented Mar 6, 2020

@hellyzh thanks for keeping track of this!
The Serial Port issue still persists when downgrading to vscode 1.42

@kowiste
Copy link

kowiste commented Mar 10, 2020

Same problem it was working perfectly and suddenly
image

@hellyzh
Copy link
Contributor

hellyzh commented Mar 10, 2020

@kowiste, it is due to VSCode auto upgraded to version 1.43, currently please use VSCode 1.42 as a workaround.

@rrakso
Copy link
Contributor

rrakso commented Mar 10, 2020

image
The same! :((

@cooperbaker
Copy link

Same here :(

downgrade is a poor solution

@Xring-git
Copy link

The same here!

@StratosMylonas
Copy link

VSCode v1.43.0
Arduino v0.2.29
Windows 10 x64
Same here...

@Christian1984
Copy link

I'm having the same issue here:

Mac OSX 10.14.6
Arduino IDE 1.8.11
VSCode 1.43.0
Arduino-Extension 0.2.29

I also had to set my port manually through arduino.json since the port selection did not work otherwise (see #922).

@duckbill70
Copy link

Hi, same issue for me:

Mac OSX 10.15.2
VSCode 1.43.0
Arduino-Extension 0.2.29

@bzeeman
Copy link

bzeeman commented Mar 12, 2020

Same issue. Honestly Microsoft, your default forced updates are almost always a problem for developers. You should rethink your choice own that when it comes to applications designed for WORK.

MacOS 10.15.3
VSCode 1.43.0
Arduino-Extension 0.2.29

@collins-kariuki
Copy link

was having the same issue;thought I had broken something :/

@hussam0O
Copy link

I have the same issue.
is there are any quick solution ?

@collins-kariuki
Copy link

collins-kariuki commented Mar 12, 2020

I have the same issue.
is there are any quick solution ?

Yes just revert to v 1.42 previous version

@PeterWone
Copy link
Contributor

PeterWone commented Mar 12, 2020

@bzeeman The problem is well understood and the workaround is public knowledge. The way to solve it is also clear. If you think it's a priority item, why don't you fork this open source project, rewrite it to use N-API and submit a PR?

That would win you a lot of friends and look excellent on your resume.

@dilin-MS
Copy link

Duplicate with #980

@apicquot
Copy link

apicquot commented Mar 24, 2020

Had the issue with
VSCode v1.43.0
Arduino v0.2.29
Windows 10 x64

Works again after downgrading to
VSCode v1.42.0
Arduino v0.2.29
Windows 10 x64

I simply downloaded https://update.code.visualstudio.com/1.42.1/win32-x64/stable and clicked for the install

@ghost
Copy link

ghost commented Jun 29, 2020

Hello folks, I'm running into the same problem. Unfortunately, "Arduino: Select Serial Port" doesn't do anything. I can manually update my arduino.json file to specify the port for my WiFi board as a workaround. I really don't want to downgrade my VSCode installation. But, I'll give that a shot down the road if this isn't an easy fix.

VSCode v1.47.0-insiders
Arduino IDE is 1.8.13
Arduino Extension is 0.3.1
Windows 10 Pro 19042.330

@ghost
Copy link

ghost commented Jun 30, 2020

Hello folks, I'm running into the same problem. Unfortunately, "Arduino: Select Serial Port" doesn't do anything. I can manually update my arduino.json file to specify the port for my WiFi board as a workaround. I really don't want to downgrade my VSCode installation. But, I'll give that a shot down the road if this isn't an easy fix.

VSCode v1.47.0-insiders
Arduino IDE is 1.8.13
Arduino Extension is 0.3.1
Windows 10 Pro 19042.330

Update, as of this morning, the problem has been resolved. When I fired up VSC, I didn't pay much attention but something updated and now the COMM Port selection and Serial Monitor are both working... I've checked my versions and nothing reflects an update. So, I don't know what updated. But, my serial connectivity is working...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests