espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

Stderr empty when calling esptool with subprocess.Popen (ESPTOOL-696) #888

Open Waganama opened 1 year ago

Waganama commented 1 year ago

Operating System

Python

Esptool Version

V4.6.1

Python Version

Python 3.11

Full Esptool Command Line that Was Run

esptool -p COM9 --chip esp32 read_mac

Esptool Output

STDOUT : b'esptool.py v4.6.1\r\nSerial port COM9\r\nConnecting......................................\r\n\r\nA fatal error occurred: Failed to connect to ESP32: No serial data received.\r\nFor troubleshooting steps visit:

https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html\r\n'

STDERR : b''

What is the Expected Behaviour?

STDOUT : b'esptool.py v4.6.1\r\nSerial port COM9\r\nConnecting......................................\r\n\r\n

STDERR : b''A fatal error occurred: Failed to connect to ESP32: No serial data received.\r\nFor troubleshooting steps visit:

https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html\r\n'"

More Information

Hello guys, I tried to catch esptool error in stderr from subprocess.Popen with the following code :

def read_mac(self, port) : command = [ESPTOOL_PY, '-p', port, '--chip', 'esp32', 'read_mac'] send_command(command)

def send_command(command: list[str]) : out = subprocess.Popen([sys.executable] + command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False) stdout, stderr = out.communicate()

print(f'STDOUT : {stdout}')
print(f'STDERR : {stderr}')

Thanks for your help :)

Other Steps to Reproduce

No response

radimkarnis commented 1 year ago

Hi @Waganama, thanks for the ticket!

It will be implemented as a part of the next major release (v5.0) since it is a breaking change for current scripts relying on reading the stdout output.

I will keep this open until then.