mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 02:06:31 +00:00
provide serial upoload port from VSC to PIO (#23436)
This commit is contained in:
parent
f5fe75c9b0
commit
a088c8791f
40
pio-tools/port-vsc.py
Normal file
40
pio-tools/port-vsc.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
if os.environ.get("PLATFORMIO_CALLER") == "vscode":
|
||||||
|
print("PIO called from VS Code extension")
|
||||||
|
import platform
|
||||||
|
import sqlite3
|
||||||
|
import json
|
||||||
|
from platformio.project.helpers import get_project_dir
|
||||||
|
|
||||||
|
os_name = platform.system()
|
||||||
|
print("OS Platform:", os_name)
|
||||||
|
os_paths = {
|
||||||
|
"Darwin": "~/Library/Application Support/Code/User/globalStorage/state.vscdb",
|
||||||
|
"Linux": "~/.config/Code/User/globalStorage/state.vscdb",
|
||||||
|
"Windows": r"%APPDATA%\Code\User\globalStorage\state.vscdb"
|
||||||
|
}
|
||||||
|
project_path = get_project_dir()
|
||||||
|
|
||||||
|
try:
|
||||||
|
db_path = os.path.expanduser(os.path.expandvars(os_paths[os_name]))
|
||||||
|
except KeyError:
|
||||||
|
raise RuntimeError("Unknown OS: " + os_name)
|
||||||
|
|
||||||
|
conn = sqlite3.connect(db_path)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
for key in ['pioarduino.pioarduino-ide', 'platformio.platformio-ide']:
|
||||||
|
cursor.execute("SELECT value FROM ItemTable WHERE key = ?", (key,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
if row:
|
||||||
|
data = json.loads(row[0])
|
||||||
|
projects = data.get("projects", {})
|
||||||
|
project = projects.get(project_path)
|
||||||
|
if project and "customPort" in project:
|
||||||
|
print("USB port set in VSC:", project["customPort"])
|
||||||
|
env["UPLOAD_PORT"] = project["customPort"]
|
||||||
|
break
|
||||||
|
conn.close()
|
@ -74,6 +74,7 @@ extra_scripts = pre:pio-tools/pre_source_dir.py
|
|||||||
pre:pio-tools/set_partition_table.py
|
pre:pio-tools/set_partition_table.py
|
||||||
pre:pio-tools/override_copy.py
|
pre:pio-tools/override_copy.py
|
||||||
pre:pio-tools/compress-html.py
|
pre:pio-tools/compress-html.py
|
||||||
|
pre:pio-tools/port-vsc.py
|
||||||
post:pio-tools/strip-flags.py
|
post:pio-tools/strip-flags.py
|
||||||
|
|
||||||
[esp_defaults]
|
[esp_defaults]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user