-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IEP-901: Changes to target and ports mapping to help user (#717)
* Changes to target and ports mapping to help user * handling exception and review comments
- Loading branch information
Showing
6 changed files
with
235 additions
and
73 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/EspToolCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/******************************************************************************* | ||
* Copyright 2023 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||
* Use is subject to license terms. | ||
*******************************************************************************/ | ||
|
||
package com.espressif.idf.core.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.espressif.idf.core.IDFConstants; | ||
|
||
/** | ||
* Class to get the commands and processes for the esptool.py | ||
* @author Ali Azam Rana | ||
* | ||
*/ | ||
public class EspToolCommands | ||
{ | ||
private Process chipInfoProcess; | ||
private Process flashEraseProcess; | ||
|
||
public Process chipInformation(String port) throws Exception | ||
{ | ||
destroyAnyChipInfoProcess(); | ||
chipInfoProcess = new ProcessBuilder(getChipInfoCommand(port)).start(); | ||
return chipInfoProcess; | ||
} | ||
|
||
public Process eraseFlash(String port) throws Exception | ||
{ | ||
destroyAnyChipInfoProcess(); | ||
flashEraseProcess = new ProcessBuilder(getFlashEraseCommand(port)).start(); | ||
return flashEraseProcess; | ||
} | ||
|
||
private List<String> getChipInfoCommand(String port) | ||
{ | ||
List<String> command = new ArrayList<String>(); | ||
command.add(IDFUtil.getIDFPythonEnvPath()); | ||
command.add(IDFUtil.getEspToolScriptFile().getAbsolutePath()); | ||
command.add("-p"); //$NON-NLS-1$ | ||
command.add(port); | ||
command.add(IDFConstants.ESP_TOOL_CHIP_ID_CMD); | ||
return command; | ||
} | ||
|
||
private List<String> getFlashEraseCommand(String port) | ||
{ | ||
List<String> command = new ArrayList<String>(); | ||
command.add(IDFUtil.getIDFPythonEnvPath()); | ||
command.add(IDFUtil.getEspToolScriptFile().getAbsolutePath()); | ||
command.add("-p"); //$NON-NLS-1$ | ||
command.add(port); | ||
command.add(IDFConstants.ESP_TOOL_ERASE_FLASH_CMD); | ||
return command; | ||
} | ||
|
||
private void destroyAnyChipInfoProcess() | ||
{ | ||
if (chipInfoProcess != null && chipInfoProcess.isAlive()) | ||
{ | ||
chipInfoProcess.destroy(); | ||
} | ||
} | ||
|
||
public boolean checkActiveFlashEraseProcess() | ||
{ | ||
if (flashEraseProcess != null) | ||
{ | ||
return flashEraseProcess.isAlive(); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public void killEraseFlashProcess() | ||
{ | ||
if (flashEraseProcess != null) | ||
{ | ||
flashEraseProcess.destroy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.