Running "make monitor" in windows command prompt or other shells

Jamesgz
Posts: 4
Joined: Sun Oct 21, 2018 3:03 pm

Running "make monitor" in windows command prompt or other shells

Postby Jamesgz » Sun Oct 21, 2018 3:36 pm

Hi guys, I am trying to use the command "make monitor" in windows command prompt or other shells other than mingw32.exe. I am using Windows 10 64bit.

Note: I want to use cmd to run a monitor command because I am trying to write a Python script to automate factory testing. The script should use subprocess to run that monitor command and terminate that command when a certain string is observed in the output, and then use that string later. I tried making subprocess open mingw32.exe to run that command but it seems like subprocess cannot live capture the output of an opened terminal properly. I also tried writing a shell script to be ran with mingw32.exe, but that did not work either.

I kind of messed up my environment variables a while ago, but I think I fixed it. I have the following environment variables set up:

Code: Select all

PROJECT_DIR = C:\Users\james\factory\factory-test\panel-table

IDF_PATH = %PROJECT_DIR%\esp-idf

PATH = 
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SystemRoot%\System32\WindowsPowerShell\v1.0\
%SystemRoot%\System32\OpenSSH\
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files (x86)\GtkSharp\2.12\bin
C:\Program Files\dotnet\
C:\Program Files (x86)\Skype\Phone\
C:\Program Files\Git\cmd
C:\Program Files\PuTTY\
C:\Program Files\CMake\bin
C:\Users\james\AppData\Local\Programs\Python\Python37
C:\Users\james\AppData\Local\Programs\Microsoft VS Code\bin
C:\msys32\usr\bin
C:\MinGW\msys\1.0\bin
C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
C:\MinGW\bin
C:\msys32\opt\xtensa-esp32-elf\bin

"make monitor" works fine in mingw32.exe (even though it says Toolchain version is not supported)

However, running "make monitor" in cmd outputs the following:

Code: Select all

C:\msys32\home\james\esp\hello_world>make monitor
WARNING: Toolchain version is not supported: 1.22.0-73-ge28a011
Expected to see version: 1.22.0-80-g6c4433a
Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
MONITOR
Traceback (most recent call last):
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monitor.py", line 754, in <module>
    main()
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monitor.py", line 670, in main
    p=serial_instance))
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monitor.py", line 72, in yellow_print
    color_print(message, ANSI_YELLOW)
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monitor.py", line 69, in color_print
    sys.stderr.write("%s%s%s\n" % (color, message,  ANSI_NORMAL))
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monitor.py", line 736, in write
    m = re.match(RE_ANSI_COLOR, self.matched)
  File "C:\Users\james\AppData\Local\Programs\Python\Python37\lib\re.py", line 173, in match
    return _compile(pattern, flags).match(string)
TypeError: cannot use a bytes pattern on a string-like object
make: *** [/c/Users/james/factory/factory-test/panel-table/esp-idf/components/esptool_py/Makefile.projbuild:106: monitor] Error 1
Running "make monitor" in git bash outputs the following:

Code: Select all

C:\Users\james\factory\factory-test\panel-table\esp-idf/make/project.mk:61: esp-idf build system only supports MSYS2 in "MINGW32" mode. Consult the ESP-IDF documentation for details.
WARNING: Failed to find Xtensa toolchain, may need to alter PATH or set one in the configuration menu
MONITOR
Traceback (most recent call last):
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monito
r.py", line 754, in <module>
    main()
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monito
r.py", line 670, in main
    p=serial_instance))
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monito
r.py", line 72, in yellow_print
    color_print(message, ANSI_YELLOW)
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monito
r.py", line 69, in color_print
    sys.stderr.write("%s%s%s\n" % (color, message,  ANSI_NORMAL))
  File "C:/Users/james/factory/factory-test/panel-table/esp-idf/tools/idf_monito
r.py", line 736, in write
    m = re.match(RE_ANSI_COLOR, self.matched)
  File "C:\Users\james\AppData\Local\Programs\Python\Python37\lib\re.py", line 1
73, in match
    return _compile(pattern, flags).match(string)
TypeError: cannot use a bytes pattern on a string-like object
make: *** [/c/Users/james/factory/factory-test/panel-table/esp-idf/components/esptool_py/Makefile.projbuild:106: monitor] Error 1
Any help would be greatly appreciated.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Running "make monitor" in windows command prompt or other shells

Postby ESP_Angus » Sun Oct 21, 2018 10:41 pm

Hi James,

The short answer is that the make-based build system only supports MINGW32.

The long answer is that the different behaviour depends on which versions of python & make are being run from each instance. The "TypeError: cannot use a bytes pattern on a string-like object" makes me think that when running cmd there's a version of Python3 on the path which is being used, and you have a version of IDF which doesn't support Python 3 yet (latest master branch builds have added Python3 support, but there's no release version with Python 3 support yet).
Note: I want to use cmd to run a monitor command because I am trying to write a Python script to automate factory testing. The script should use subprocess to run that monitor command and terminate that command when a certain string is observed in the output, and then use that string later.
I tried making subprocess open mingw32.exe to run that command but it seems like subprocess cannot live capture the output of an opened terminal properly.
The idf_monitor tool that "make monitor" invokes is designed to run in an interactive terminal.

Do you only need to capture serial data? If so, I'd recommend using the "pyserial" API directly rather than invoking any subprocess at all. You can read from the serial port and read/write data as needed, and also manipulate DTR/RTS if required to reset the target.

The only real difference to capturing "make monitor" output is that automatic address decoding won't work, but it doesn't seem like you need this feature...?

Jamesgz
Posts: 4
Joined: Sun Oct 21, 2018 3:03 pm

Re: Running "make monitor" in windows command prompt or other shells

Postby Jamesgz » Thu Oct 25, 2018 9:18 am

Thanks a lot! Pyserial worked perfectly.

Who is online

Users browsing this forum: Bing [Bot] and 76 guests