Skip to content

Commit

Permalink
Filter serial devices by default and allow user to disable chip id in…
Browse files Browse the repository at this point in the history
… serial port list (#1276)

* add usb filter and optional esptool py chip id request to serial port list

* fix read wrong setting return resolve

* add usb filter list as setting

* add usb cdc acm

* update settings docs

* update action upload artifact

* use lowercase for windows pid vid cases
  • Loading branch information
brianignacio5 authored Sep 13, 2024
1 parent 98a4d94 commit e31b39d
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: echo "${{ steps.idftest.outputs.result }}" | tee test-result.xml

- name: Upload if failed test results
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-result.xml
Expand All @@ -44,7 +44,7 @@ jobs:
run: yarn package

- name: Upload .vsix File
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: esp-idf-extension.vsix
path: esp-idf-extension.vsix
2 changes: 1 addition & 1 deletion .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: /ui-entrypoint.sh

- name: Upload screenshots
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ results/
report.txt
report.json
test-resources/**
/docs_espressif/__pycache__/
/docs_espressif/.venv/
/docs_espressif/_build/
/docs_espressif/.DS_Store
/docs_espressif/en/.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions docs/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ These settings are specific to the ESP32 Chip/Board
| `idf.openOcdDebugLevel` | Set OpenOCD Debug Level (0-4) Default: 2 | |
| `idf.port` | Path of Selected Device port | |
| `idf.portWin` | Path of Selected Device Port in Windows | |
| `idf.enableSerialPortChipIdRequest` | Enable detecting the chip id and show on serial port selection list | |
| `idf.useSerialPortVendorProductFilter` | Enable use of idf.usbSerialPortFilters list to filter serial port devices list | |
| `idf.usbSerialPortFilters` | USB productID and vendorID list to filter known Espressif devices | |
| `openocd.jtag.command.force_unix_path_separator` | Forced to Use `/` as Path sep. for Win32 Based OS Instead of `\\` | User, Remote or Workspace |
| `idf.listDfuDevices` | List of DFU Devices Connected to USB | User, Remote or Workspace |
| `idf.selectedDfuDevicePath` | Selected DFU Device Connected to USB | User, Remote or Workspace |
Expand Down
7 changes: 6 additions & 1 deletion docs_espressif/en/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ These settings are specific to the ESP32 Chip/Board
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **idf.portWin** | Path of Selected Device Port in Windows |
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **idf.enableSerialPortChipIdRequest** | Enable detecting the chip id and show on serial port selection list |
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **idf.useSerialPortVendorProductFilter** | Enable use of idf.usbSerialPortFilters list to filter serial port devices list |
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **idf.usbSerialPortFilters** | USB productID and vendorID list to filter known Espressif devices |
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **openocd.jtag.command.force_unix_path_separator** | Forced to Use ``/`` as Path sep. for Win32 Based OS Instead of ``\\`` |
+----------------------------------------------------+----------------------------------------------------------------------------------------+
| **idf.listDfuDevices** | List of DFU Devices Connected to USB |
Expand All @@ -107,7 +113,6 @@ These settings are specific to the ESP32 Chip/Board
| **idf.svdFilePath** | SVD File Absolute Path to Resolve Chip Debug Peripheral Tree view |
+----------------------------------------------------+----------------------------------------------------------------------------------------+


This is how the extension uses them:

1. **idf.adapterTargetName** is used to select the chipset (esp32, esp32s2, esp32s3, esp32c3 and custom) on which to run the extension commands.
Expand Down
69 changes: 69 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,75 @@
"scope": "resource",
"default": "espidf.spdx",
"description": "%param.sbomFilePath.title%"
},
"idf.enableSerialPortChipIdRequest": {
"type": "boolean",
"scope": "application",
"default": true,
"description": "%param.enableSerialPortChipIdRequest.title%"
},
"idf.useSerialPortVendorProductFilter": {
"type": "boolean",
"scope": "application",
"default": false,
"description": "%param.useSerialPortVendorProductFilter.title%"
},
"idf.usbSerialPortFilters": {
"type": "object",
"scope": "application",
"description": "%param.usbSerialPortFilters.title%",
"additionalProperties": {
"type": "object",
"properties": {
"vendorId": {
"type": "string",
"description": "%param.usbSerialPortFilters.vendorId%"
},
"productId": {
"type": "string",
"description": "%param.usbSerialPortFilters.productId%"
}
},
"additionalProperties": false
},
"default": {
"CP2102/CP2102N": {
"vendorId": "0x10c4",
"productId": "0xea60"
},
"FT2232H": {
"vendorId": "0x0403",
"productId": "0x6010"
},
"Espressif USB_SERIAL_JTAG": {
"vendorId": "0x303a",
"productId": "0x1001"
},
"Espressif esp-usb-bridge firmware": {
"vendorId": "0x303a",
"productId": "0x1002"
},
"ESP32-S2 USB_CDC": {
"vendorId": "0x303a",
"productId": "0x0002"
},
"ESP32-S3 USB_CDC": {
"vendorId": "0x303a",
"productId": "0x0009"
},
"CH9102F": {
"vendorId": "0x1a86",
"productId": "0x55d4"
},
"CH340T": {
"vendorId": "0x1a86",
"productId": "0x7523"
},
"FT232R": {
"vendorId": "0x0403",
"productId": "0x6001"
}
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"param.uncoveredLightTheme": "Color de fondo para líneas no cubiertas en tema claro para Cobertura de ESP-IDF.",
"param.useIDFKConfigStyle": "Habilitar/Deshabilitar validación de estilo ESP-IDF para archivos Kconfig",
"param.hintsViewer.title": "Ruta al archivo de sugerencias.",
"param.enableSerialPortChipIdRequest.title": "Habilite la detección de la identificación del chip y muéstrela en la lista de selección del puerto serie",
"param.useSerialPortVendorProductFilter.title": "Utilice el USB productID y el USB vendorID para filtrar dispositivos Espressif conocidos",
"param.usbSerialPortFilters.title": "Lista de USB productID y de USB vendorID para filtrar",
"param.usbSerialPortFilters.vendorId": "Número hexadecimal del USB vendorID como texto.",
"param.usbSerialPortFilters.productId": "Número hexadecimal del USB productID como texto.",
"trace.poll_period.description": "poll_period se establecerá para el rastreo de la aplicación",
"trace.skip_size.description": "skip_size se establecerá para el rastreo de la aplicación",
"trace.stop_tmo.description": "stop_tmo se establecerá para el rastreo de la aplicación",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"param.uncoveredLightTheme": "Background color for uncovered lines in Light theme for ESP-IDF Coverage.",
"param.useIDFKConfigStyle": "Enable/Disable ESP-IDF style validation for Kconfig files",
"param.hintsViewer.title": "Path to the hints file.",
"param.enableSerialPortChipIdRequest.title": "Enable detecting the chip id and show on serial port selection list",
"param.useSerialPortVendorProductFilter.title": "Use USB productID and vendorID to filter known Espressif devices",
"param.usbSerialPortFilters.title": "USB serial port productID and vendorID list to filter",
"param.usbSerialPortFilters.vendorId": "USB Vendor ID hex number as string. Format is 0x0403",
"param.usbSerialPortFilters.productId": "USB Product ID hex number as string. Format is 0x6010",
"trace.poll_period.description": "poll_period will be set for the apptrace",
"trace.skip_size.description": "skip_size will be set for the apptrace",
"trace.stop_tmo.description": "stop_tmo will be set for the apptrace",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
"param.uncoveredDarkTheme": "Cor de fundo para linhas descobertas no tema Dark para cobertura ESP-IDF.",
"param.uncoveredLightTheme": "Cor de fundo para linhas descobertas no tema Light para cobertura ESP-IDF.",
"param.useIDFKConfigStyle": "Habilitar/desabilitar validação de estilo ESP-IDF para arquivos Kconfig",
"param.enableSerialPortChipIdRequest.title": "Habilite a detecção do ID do chip e mostre na lista de seleção de porta serial",
"param.useSerialPortVendorProductFilter.title": "Use USB productID e vendorID para filtrar dispositivos Espressif conhecidos",
"param.usbSerialPortFilters.title": "Lista de productID e vendorID da porta serial USB para filtrar",
"param.usbSerialPortFilters.vendorId": "Número hexadecimal do USB vendorID como string.",
"param.usbSerialPortFilters.productId": "Número hexadecimal de USB productID como string.",
"trace.poll_period.description": "poll_period será definido para o apptrace",
"trace.skip_size.description": "skip_size será definido para o apptrace",
"trace.stop_tmo.description": "stop_tmo será definido para o apptrace",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"param.uncoveredLightTheme": "Цвет фона для непокрытых линий в светлой теме для покрытия ESP-IDF.",
"param.useIDFKConfigStyle": "Включить/отключить проверку стиля ESP-IDF для файлов Kconfig.",
"param.hintsViewer.title": "Путь к файлу подсказок",
"param.enableSerialPortChipIdRequest.title": "Включить определение идентификатора чипа и отобразить его в списке выбора последовательного порта.",
"param.useSerialPortVendorProductFilter.title": "Используйте USB ProductID и VendorID для фильтрации известных устройств Espressif.",
"param.usbSerialPortFilters.title": "Список идентификаторов продуктов и идентификаторов поставщиков для последовательного порта USB для фильтрации",
"param.usbSerialPortFilters.vendorId": "Шестнадцатеричный номер USB VendorID в виде строки. ",
"param.usbSerialPortFilters.productId": "Шестнадцатеричный номер USB ProductID в виде строки. ",
"trace.poll_period.description": "poll_ period будет установлен для apptrace",
"trace.skip_size.description": "Skip_size будет установлен для трассировки приложения.",
"trace.stop_tmo.description": "stop_tmo будет установлен для apptrace",
Expand Down
5 changes: 5 additions & 0 deletions package.nls.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"param.uncoveredLightTheme": "在 ESP-IDF 覆盖率的浅色主题中未覆盖的行的背景颜色。",
"param.useIDFKConfigStyle": "启用/禁用 Kconfig 文件的 ESP-IDF 样式验证",
"param.hintsViewer.title": "提示文件的路径",
"param.enableSerialPortChipIdRequest.title": "启用检测芯片 ID 并显示在串口选择列表上",
"param.useSerialPortVendorProductFilter.title": "使用 USB 产品 ID 和供应商 ID 过滤已知的乐鑫设备",
"param.usbSerialPortFilters.title": "USB串口productID和vendorID列表进行过滤",
"param.usbSerialPortFilters.vendorId": "USB VendorID 十六进制数字作为字符串。",
"param.usbSerialPortFilters.productId": "USB ProductID 十六进制数字作为字符串。",
"trace.poll_period.description": "将为 apptrace 设置 poll_period",
"trace.skip_size.description": "将为 apptrace 设置 skip_size",
"trace.stop_tmo.description": "将为 apptrace 设置 stop_tmo",
Expand Down
36 changes: 35 additions & 1 deletion src/espIdf/serial/serialPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { spawn } from "../../utils";
import { SerialPortDetails } from "./serialPortDetails";
import { OutputChannel } from "../../logger/outputChannel";
import * as SerialPortLib from "serialport";
import { ESP } from "../../config";

export class SerialPort {
public static shared(): SerialPort {
Expand Down Expand Up @@ -93,7 +94,7 @@ export class SerialPort {
return;
}

const choices = listOfSerialPorts.map((item) => {
let choices = listOfSerialPorts.map((item) => {
return new SerialPortDetails(
item.path,
item.manufacturer,
Expand All @@ -109,6 +110,39 @@ export class SerialPort {
"idf.espIdfPath",
workspaceFolder
);
const enableSerialPortChipIdRequest = idfConf.readParameter(
"idf.enableSerialPortChipIdRequest",
workspaceFolder
) as boolean;
const useSerialPortVendorProductFilter = idfConf.readParameter(
"idf.useSerialPortVendorProductFilter",
workspaceFolder
) as boolean;
const usbSerialPortFilters = idfConf.readParameter(
"idf.usbSerialPortFilters",
workspaceFolder
) as { [key: string]: { vendorId: string; productId: string } };
if (useSerialPortVendorProductFilter) {
const filterDictKeys = new Set<string>(
Object.keys(usbSerialPortFilters).map((key) => {
const { vendorId, productId } = usbSerialPortFilters[key];
return `${vendorId ? vendorId.toLowerCase() : undefined}-${
productId ? productId.toLowerCase() : undefined
}`;
})
);
choices = choices.filter(({ vendorId, productId }) => {
const key = `0x${vendorId ? vendorId.toLowerCase() : undefined}-0x${
productId ? productId.toLowerCase() : undefined
}`;
return filterDictKeys.has(key);
});
}

if (!enableSerialPortChipIdRequest) {
return resolve(choices);
}

const esptoolPath = join(
idfPath,
"components",
Expand Down

0 comments on commit e31b39d

Please sign in to comment.