bugfix: Fix port autodetection with esptool package

This commit is contained in:
radim.karnis 2022-04-27 10:08:14 +02:00 committed by BOT
parent 8cb780ffcd
commit 1cdaf4a831

View File

@ -26,10 +26,8 @@ def action_extensions(base_actions, project_path):
def _get_default_serial_port(args):
# Import is done here in order to move it after the check_environment() ensured that pyserial has been installed
try:
import serial.tools.list_ports
esptool_path = os.path.join(os.environ['IDF_PATH'], 'components/esptool_py/esptool/')
sys.path.insert(0, esptool_path)
import esptool
import serial.tools.list_ports
ports = list(sorted(p.device for p in serial.tools.list_ports.comports()))
# high baud rate could cause the failure of creation of the connection
esp = esptool.get_default_connected_device(serial_list=ports, port=None, connect_attempts=4,