Checking status of lauterbach window command line - trace32

We use Perl script to launch a trace32 window on a remote machine and perform some operation, obviously the Perl cannot print any logs from trace32 window as its a separate GUI, very rarely the script fails probably because the trace32 failed, but there is no way to check in Perl script log about the trace32 failure, is there a command line option available to fetch the status or the error message printed in trace32 window ? thanks.

Maybe it is too late now, but for others looking for the same answer, what I did was save the B::area window log into a file and regex that file to my heart's content.
Here's a sample command to do it:
Prt.file C:\some\path\log.txt
winprint.area A000
prt.file
This can be done to any window area, by default the B::area window name is A000 that i know of.

Area.View is the command to view the status messages and various operations performed during debugging on trace32. When the command is run, trace32 displays an window named "B::area.view".The contents of window can be saved to a text file and later parsed to check the error using perl. Hope this hepls.

The default location for printing error or status messages is the AREA window with the ID "A000".
TRACE32 has commands for logging its contents to a file:
AREA.OPEN A000 protocol.lst ; area will be saved in 'protocol.lst'
DO test
...
AREA.CLOSE A000 ; all messages will be saved
AREA.OPEN <id_area> <file> opens a file for logging and directs all messages to be printed in the selected AREA window to it.
AREA.CLOSE <id_area> stops the logging.
Please refer to the file ide_ref.pdf for a detailed description of these commands.

Related

How to determine which PER file is loaded in the current session of Trace-32

In a running Trace-32 Debugging Session, can you please tell me how to determine the currently loaded PER file name using some commands?
Thank you.
Regards
The file shown by the PER or PER.view command is (when no explicit filename is used)
the last file used with the command PER.ReProgram
the last file for which the "Compile" button was pressed in the PER.Program editor
the default-peripheral file for the selected CPU if the two above
haven't happened
In any case you can see the name of the file shown by PER or PER.view (when no explicit filename is used) in the window VERSION.Software.
The VERSION.Software window does not refresh automatically. So re-open the window, to get the latest results.

SAS Error Handling in Windows Batch

I have a scheduled SAS program in Windows, e.g.
sas.exe -nosplash -icon -sysin "myprogram.sas"
This process will hang if there's an "Out of Resources" error (e.g. no disk space), prompting for user input (Retry, Cancel, etc.). As it's a batch job, there is no user to give that input.
Is there a SAS system option which prevents the prompt for user input so it can be dealt with in the code itself?
How about -noterminal?
Extract from documentation:
If NOTERMINAL is specified, dialog boxes are not displayed.
Trying using the option
-batch
Since you are running in batch mode, also consider using the option
-errorabend
The best option is
-get_more_resources ;)
If the program is the cause to the resource error you have another question to ask!

iTerm2 Coprocess Debugging

I'm attempting to develop a coprocess plugin in python for iTerm2 but am running into some issues. I have a script that takes input from STDIN and sends it across the network to a listening daemon. This works fine when run from the command line, however when I activate the coprocess either via the menu or a trigger I just see a brief flash of the coprocess icon in the upper right corner. Googling does not reveal whether or not iTerm2 sends output anywhere that I can examine. I have looked at all of the system logs in Console.app but there is nothing there. I've also tried Toggling the Debug Logging in iTerm but I do not see any coprocess data in there. Anyone know if/where to find the STDOUT/STDERR of a coprocess script?
Stdin and stdout are hooked up to the tty as described in copresses documentation (and may be silent or visible depending on how it is set up). As for stderr, (judging by the lack of any redirect of fd 2 in Coprocess.m source) it is the same as stderr of iTerm2 itself. In order to see the error of copresseses, you can launch iTerm2 from Terminal in the foreground (open /Applications/iTerm.app/Contents/MacOS/iTerm2), interact with iTerm2, and view the stderr within Terminal.

Command line interface for Lauterbach

I am using Lauterbach debugger (TRACE32 interface) on a 7447 processor. I need to load multiple files onto this processor which I do by running commands in the T32 GUI. Idea is to have a script do the job. One way is to call individual .cmm files in the startup.cmm. But this encounters a problem each time the GUI pops-up a dialog box which again requires a manual input. Can anyone tell me how to use command line interface on T32 to achieve the same?
A target program is normally loaded to your CPU's memory with the command
Data.LOAD.Elf myprog.elf
However TRACE32 deletes the symbol data base every time you use Data.LOAD.Elf before loading your new target program. To suppress that use option "/NoClear".
So if you want to load more than one ELF (target program) to your CPU's memory you should do it like this:
Data.LOAD.Elf myprog1.elf
Data.LOAD.Elf myprog2.elf /NoClear
Data.LOAD.Elf myprog3.elf /NoClear
If you use the Data.LOAD commands in one *.cmm script file or in several *.cmm script files is up to you, but I would put it one cript.
A dialog box should not pop-up.
In case someone still needs an answer.
My script to load elf file:
flash-elf.cmm:
local &fileName
entry &fileName
print "LOAD &fileName"
IF (!FILE.EXIST(&fileName))
(
PRINT "No elf file was flashed"
ENDDO
// T32 will stay opened
)
DO ~~/demo/powerpc/flash/mpc574xg.cmm "PREPAREONLY" // you should choose your cpu script
FLASH.ReProgram ALL
Data.LOAD.Elf &fileName
FLASH.ReProgram off
SYStem.ResetTarget
GO
QUIT
save it either in you home directory (or bin, or any directory that PATH points to) or even next to t32.config (where T32 installed, that's what I use)
now from CMD I call
t32mppc.exe -s ~~/flash-elf.cmm my.elf
Here's an answer on how to control T32 via TCP/UDP
https://stackoverflow.com/a/39400777/4875690
I have faced the same problem and finally, I have figured out that the popup dialog box has been created from the PRACTICE Script (.cmm).
So just check out your PRACTICE Script (.cmm) and remove the code that is creating the popup dialog box.
The below code is an example for the code that creates Yes/No dialog box from a PRACTICE Script (.cmm)
LOCAL &result
DIALOG.YESNO "Program FLASH memory?"
ENTRY &result
IF &result==FALSE()
ENDDO
PRINT "User clicked Yes."
The above example is from here (https://www2.lauterbach.com/pdf/ide_ref.pdf).
For controlling trace32 via the command line, please check out this (controlling trace32 via command line).

Suppress system("ping") output in C++

I have written a simple program that pings three sites and then reacts to whether they are reachable or not.
My question is: can I suppress system("ping ")'s output? I have written my code in C++ as I know that language the best. Currently the code opens the ping.exe running the system command. If I can prevent the output from showing up while it still pings that would be ideal.
I am eventually going to turn this program in a windows service that is why I would like to suppress both the command line console window as well as suppress the ping output. Thanks.
Try doing system("ping host > nul") (nul is windows equivalent of UNIX /dev/null).
Generally, if you're going to call another program but don't want it to act like std::system, you're going to need a platform-specific function like fork()/exec() on UNIX or CreateProcess() on Windows. These functions give you control over how the other program runs, for instance, that it not show output or not create a console window, etc.
You can use system command like below to suppress the output of ping command.
system("ping 100.100.100.100 > response.dat");
Above command pings IP address 100.100.100.100 and directs the output to a file called response.dat. In response.dat you can see the response of ping command.
Do system( "ping site.com >nul 2>nul" ); and check the value the shell returns.
if the ping succeeds, the shell will return 0, else it will return 1.
I would be more detailed, but Vis Studio is reinstalling itself. :)
There's also a way to hide the console window using the Win API to exec the command, but...
I do not remember the details.
Edit:
I'm still waiting for the MSVS install process, so... :)
Use CreateProcess with the DETACHED_PROCESS flag for the dwCreationFlags parameter to hide the console window.
After you call create process, you'll have to use WaitForSingleObject on the process handle to wait for the ping to complete. The last parameter to CreateProcess should have a pointer to process information that contains the process handle. (Assuming CreateProcess was successful) You have to wait for the command to complete. Once it's complete, you can use the process handle to get the return value, though I'm too time contstrained to tell you how to do that at this point.
When you get over to Windows and call CreateProcess(), be sure to set:
lpStartupInfo->wShowWindow = SW_HIDE;
This will ensure that any windows created by the new process are hidden.
Using the DETACHED_PROCESS flag will prevent the new process from inheriting your application's console, but that does not prevent the new process from creating a new console. Not sure what ping would do, but best to remove all doubt by using SW_HIDE.
You could also use this way, this will return the output in a file and doesn't show up a console windows and freezes the main application which is really usefull.
At first you need to include the Windows header using;
#include <Windows.h>
then send a ping command and write the output into a file like this;
WinExec("ping google.com > file.dat", SW_HIDE);
This will send a ping command to google.com and writes the output to the file 'file.dat' in the directory of your current running program. So you could change file.dat to any file or filepath you want and of course you could change the ping command. The > character means that the output of the command needs to be wrote in the file path behind it.
If you want to show the console window and freeze the application while running the ping command you need to use the following line of code instead of the WindExec() code;
system("ping google.com > file.dat");