Skip to main content
bartj1
Associate III
August 22, 2022
Question

Using STM32_programmer_CLI.exe how can I capture the STD output?

  • August 22, 2022
  • 2 replies
  • 966 views

Running in vb.net I can successfully load code to a target using a .bat file using:

System.Diagnostics.Process.Start("c:\rp:\boot.bat")

In the above case a command window is shown during the load with session information. It goes away when complete.

However, if I launch the bat file as a "process" and look for the STD output, I get nothing. However the "process" loads a file correctly.

 ' define a process

           Dim p As New Process

           p.StartInfo.FileName = "boot.bat"                 

           p.StartInfo.UseShellExecute = False

           p.StartInfo.RedirectStandardOutput = True

           p.StartInfo.RedirectStandardError = True

           p.StartInfo.CreateNoWindow = True

           p.EnableRaisingEvents = True

           Application.DoEvents()

           ' add a handler so we can easily display the data

           AddHandler p.OutputDataReceived, AddressOf Showme

           

           p.Start()

           p.BeginOutputReadLine()

           Application.DoEvents()

           ' spin here till done or cancel

           Do While (p.HasExited = False) And (CANCEL = False)

               ' monitor progress

               Application.DoEvents()

           Loop

       I never get an event on OutputDataReceived. Does the cli version issue standard output? If not, is there a good workaround?

Thanks!

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
August 22, 2022

Are you sure it's coming out of STDOUT (1) and not STDERR (2) ?

Piping the latter

foo 2>err.log

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
bartj1
bartj1Author
Associate III
August 22, 2022

First...thank you for your response...

Two findings:

1) If I add:

p.StartupInfo.Arguments = "> " & Echofile

The file is correctly populated with the load session info.

2) If I add:

p.StartupInfo.RedirectStandardError = True

p. ErrorDataReceived, Addressof Showmeerror

I still never get a "hit" on the above event.

Any additional ideas?

Thanks