launch.json
...
"preLaunchTask": "startDebug",
"postDebugTask": "closeOpenOCDTerminal"
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "startDebug",
"type": "shell",
"command": "make -j4; openocd -f interface/cmsis-dap.cfg -c 'transport select swd' -f target/stm32f1x.cfg",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": "."
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "closeOpenOCDTerminal",
"type": "process",
"command":[
"${command:workbench.action.tasks.terminate}",
// "${command:workbench.action.acceptSelectedQuickOpenItem}" //invalid
]
}
]
}
The OpenOCD service does not end automatically like the make command, only depends on closing the terminal or executing Ctrl + C. How to automatically close the task terminal after debugging? Or execute Ctrl + C command automatically in the task terminal to end the Openocd service. The currently used closeOpenOCDTerminal method requires manual clicking on the pop-up list.