vscode怎么打开终端(vscode 打开终端)

终端页面怎么写

方法如下:

1.点击桌面的vscode小图标,打开vscode软件。

2.点击vscode软件上的终端功能,选择新建终端,或者直接按键盘上快捷键Ctrl+shift+`来新建终端页面。

3.这时候vscode底部就会显示一个新建的终端页面了,接下来就可以编写了。

**GNU Screen**是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。

vscode怎么运行代码

1、通过快捷方式打开Visual Studio Code工具,然后新建静态页面。

2、创建一个静态页面table.html,并添加页面代码,然后保存,使用浏览器查看。

3、点击File菜单,选择Open Folder,将项目导入到Visual Studio Code。

4、导入进去后,查看项目所依赖的包是否安装,项目配置文件。

5、新建一个终端窗口,在命令行输入npm run dev运行项目。

6、再点击File,然后新建一个TypeScript文件ct.ts,添加对应的代码。

7、打开一个终端窗口,查看是否安装TypeScript插件,利用tsc命令运行文件。

esp32 vscode lauch 设置

第一步:安装 VSCode C/C++ 扩展

1.在应用商店里搜索 C++

2.安装C/C++ IntelliSense, debugging, and code browsing

第二步:安装 VSCode ESP-IDF 扩展

1.在应用商店里搜索 Espressif

2.安装 Develop and debug applications for Espressif ESP32, ESP32-S2 chips with ESP-IDF (带乐鑫图标)

第三步:配置ESP-IDF 扩展

1.按 F1 或Ctrl+Shift+P 打开命令面板

2.输入 ESP-IDF: Configure ESP-IDF extension

加载初始设置时间较长,耐心等待

3.根据实际情况选择不同的配置方式

Express: IDF 版本 配置Python环境,扩展将安装IDF

Advanced: 手动配置已安装的开发环境

Using Existing Setup : 使用扩展检测出的环境

配置完成后显示:All settings have been configured. You can close this window.

第四步:创建项目模板,检测设置

1.按 F1 或Ctrl+Shift+P 打开命令面板 输入ESP-IDF:Create project 或按Ctrl+E+C

2.选择工程创建目录

3.选择模板类型

第五部:设置工作区的json文件

在settings.json文件中添加以下内容

"terminal.integrated.shell.windows": "cmd.exe",

"terminal.integrated.shellArgs.windows": ["/k", "c:\\esp\\esp-idf\\export.bat"],

"terminal.integrated.shell.linux": "/bin/bash",

"terminal.integrated.shellArgs.linux": ["--init-file", "~/esp/esp-idf/export.sh", "-i"],

"terminal.integrated.shell.osx": "/bin/bash",

"terminal.integrated.shellArgs.osx": ["--init-file", "~/esp/esp-idf/export.sh", "-i"],

"files.associations": {undefined

"*.md": "markdown",

"*.mdx": "tdx",

"stdio.h": "c"

},

可以在VSCode 终端中正常使用idf的各种命令。

第六步:编译工程

可以使用ESP扩展下的各个按钮完成项目的串口选择、项目配置、Full Clearn、编译、下载、监视

也可以使用命令行方式:

1.按Ctrl+` (~按键的位置)打开终端(第一次运行时扩展会有提示,选择允许 其实质就是运行~/esp/esp-idf/export.sh)

2.选择终止终端

3.重新打开终端 会看到export.sh运行的结果

Go to the project directory and run:

idf.py build

4.运行各种idf命令

第七部:下载程序并监测程序运行

1. 按Select Device Port 按钮 或运行 ESP-IDF:Device configuration命令

按提示选择/dev/ttyUSB1作为下载口

2.编译完成后,可使用下载按钮进行程序下载。此时会出现提示:

PermissionError: [Errno 13] Permission denied: '/dev/ttyUSB1'

原因:

$ ls -l /dev/ttyUSB*

crw-rw---- 1 root dialout 188, 0 2月 3 11:21 /dev/ttyUSB0

crw-rw---- 1 root dialout 188, 1 2月 3 11:21 /dev/ttyUSB1

发现ttyUSB* 设备属于root用户 dialout 用户组,当前用户不属于dialout用户组

解决方案:

(1).执行以下命令

$sudo chmod 666 /dev/ttyUSB*

修改ttyUSB设备权限为其它用户可读可写。

缺点:电脑重启后,又会出现这种问题,还要重新设置

(2).为了能让普通用户也能使用串口,可以增加udev规则来实现

$sudo vim /etc/udev/rules.d/70-ttyusb.rules

增加如下内容:

KERNEL=="ttyUSB[0-9]*",MODE="0666"

保存,重新插入USB转串口,普通用户就能搞定了

缺点:该方法会让所有的普通用户都具有访问这些串口设备的权限,存在一定的安全隐患

(3).将目标用户加入dialout用户组,可以使用以下任意一个命令

$sudo usermod -aG dialout 目标用户名

或:

sudo gpasswd --add 目标用户名 dialout

重启系统即可

第八部:跟踪调试程序

1.按 OpenOCD Server 按钮 输出提示:

❌ Error: libusb_open() failed with LIBUSB_ERROR_ACCESS

❌ Error: no device foun

按照 文档解释做如下操作:

(1). 将~/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200709/openocd-esp32/share/openocd/contrib/

目录下的 60-openocd.rules 拷贝至 /etc/udev/rules.d/ 目录下

(2).确保当前用户属于 plugdev 用户组。 提示:运行 groups 命令可以查看当前用户所属的用户组

(3).重启系统

2.配置Debug 环境

参考:

注:该文档中的模板有坑。

问题:

使用 ESP-IDF Debug Adapter 配置时出现如下提示:

pygdbmi.gdbcontroller.NoGdbProcessError: gdb process has already finished with return code: 127

按照 esp_debug_adapter 说明文档 在~/.vscode/extensions/espressif.esp-idf-extension-0.6.1/esp_debug_adapter/ 目录下

$pip install -r requirements.txt

问题依然存在 暂无解决思路

使用 Microsoft C/C++ extension to debug 配置时出现如下提示:

error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

实质是系统中没有python2.7的库,解决:

$ sudo apt update

$ sudo apt upgrade

$ sudo apt install libpython2.7

问题解决

同时也解决了使用 ESP-IDF Debug Adapter 配置时出现的问题 故是否需要pip install …… 不能确定

在使用 Microsoft C/C++ extension to debug 配置时 会提示出现异常,不用理会可正常跟踪调试。

有时会提示

Error: couldn’t bind tcl to socket: Address already in use

则证明 刚刚启动的 进程未被终止。

解决办法:

a).查看当前活动进程

netstat为显示网络相关信息 a(all:默认显示所有,如果加了其他选项此项不生效) n(number:以数字形式显示) t(仅仅显示tcp连接),p(process:显示该项是由哪个程序建立起来的)

$ sudo netstat -antp

b). 强制杀死它(假设进程号为3560,-9为强制杀死)

$ sudo kill -9 3560

Debug正常运行时,状态栏由蓝色变为棕色。

附:scode的各个json文件

c_cpp_properties.json

======================================

{undefined

"configurations": [

{undefined

"name": "ESP-IDF",

"compilerPath": "${default}",

"cStandard": "c11",

"cppStandard": "c++17",

"includePath": [

"${config:idf.espIdfPath}/components/**",

"${config:idf.espIdfPathWin}/components/**",

"${workspaceFolder}/**"

],

"browse": {undefined

"path": [

"${config:idf.espIdfPath}/components",

"${config:idf.espIdfPathWin}/components",

"${workspaceFolder}"

],

"limitSymbolsToIncludedHeaders": false

}

}

],

"version": 4

}

settings.json

======================================

{undefined

"terminal.integrated.shell.windows": "cmd.exe",

"terminal.integrated.shellArgs.windows": ["/k", "c:\\esp\\esp-idf\\export.bat"],

"terminal.integrated.shell.linux": "/bin/bash",

"terminal.integrated.shellArgs.linux": ["--init-file", "~/esp/esp-idf/export.sh", "-i"],

"terminal.integrated.shell.osx": "/bin/bash",

"terminal.integrated.shellArgs.osx": ["--init-file", "~/esp/esp-idf/export.sh", "-i"],

"files.associations": {undefined

"*.md": "markdown",

"*.mdx": "tdx",

"stdio.h": "c"

},

"C_Cpp.clang_format_style": "Visual Studio",

"editor.formatOnSave": false,

"[cpp]": {undefined

"editor.quickSuggestions": true

},

"[c]": {undefined

"editor.quickSuggestions": true

},

"C_Cpp.intelliSenseEngine": "Tag Parser",

//配置下载接口

"idf.port": "/dev/ttyUSB1",

//配置下载方式

"idf.flashType": "UART",

//openOcd配置,根据开发板确定

"idf.openOcdConfigs": [

//新版建议用“board/XXX” 配置

"interface/ftdi/esp32_devkitj_v1.cfg",

"target/esp32.cfg"

]

}

launch.json

======================================

{undefined

// Use IntelliSense to learn about possible attributes.

// Hover to view descriptions of existing attributes.

// For more information, visit:

"version": "0.2.0",

"configurations": [

{undefined

"type": "espidf",

"name": "ESP_Debug",

"request": "launch",

"debugPort": 43474,

"logLevel": 2,

//模板中有坑的地方,模板内容为 "mode": "manual",

//这样不能自动启动 Debug Adapter

"mode": "auto",

"initGdbCommands": [

"target remote :3333",

"symbol-file ${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",

"set remote hardware-watchpoint-limit 2",

"mon reset halt",

"flushregs",

"thb app_main",

"c"

],

"env": {undefined

"PATH": "${env:PATH}:${config:idf.customExtraPaths}"

}

},

{undefined

"name": "GDB",

"type": "cppdbg",

"request": "launch",

"MIMode": "gdb",

"miDebuggerPath": "${command:espIdf.getXtensaGdb}",

"program": "${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",

"windows": {undefined

"program": "${workspaceFolder}\\build\\${command:espIdf.getProjectName}.elf"

},

"cwd": "${workspaceFolder}",

"environment": [{ "name": "PATH", "value": "${config:idf.customExtraPaths}" }],

"setupCommands": [

{ "text": "-enable-pretty-printing",

"ignoreFailures": true },

{ "text": "file '${workspaceFolder}/build/${command:espIdf.getProjectName}.elf'"},

{ "text": "target remote :3333" },

{ "text": "set remote hardware-watchpoint-limit 2"},

{ "text": "mon reset halt" },

{ "text": "thb app_main" },

{ "text": "flushregs" }

//{ "text": "c"}

],

"externalConsole": false,

"logging": {undefined

"engineLogging": true

}

}

]

}

tasks.json 这个文用系统生成的即可 略

————————————————

版权声明:本文为CSDN博主「FuShaofeng」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:

VSCode修改默认终端

打开设置

搜索[shell:windows]

修改或者增加配置行: "terminal.integrated.shell.windows": "D:\\Git\\bin\\bash.exe"

配置完之后打开终端就是打开配置好的bash终端了

361知讯网

本文链接:http://pdidw.com/vs/585.html

发表评论

评论列表

还没有评论,快来说点什么吧~