how to quit currently running Trace32 from command line - trace32

I am doing the automate regression with Trace32. Before the regression starts, if any Trace32 process is in use, I want to kill the process. The problem is, if I kill it with system OS, when regression starts, the GUI will pop up a dialog saying "TRACE32 device already in use. Reset device and connect?" I have to manually click yes to continue to regression. Is there any way to quit the currently running Trace32 properly from command line, such that the reset dialog will not show when Trace32 starts next time. Or any command I can add to the .cmm file in my regression to skip this question dialog. I have tried to put RESet initially in .cmm, which does not help.

First of all try to end all your automated test with TRACE32 command QUIT. This will close TRACE32. However something might go wrong in your tests and thus, the QUIT command might not get reached and TRACE32 is still running.
So secondly start TRACE32 with an open Remote-API port. Add to your TRACE32 config-file (by default this is c:\T32\config.t32) the following lines
RCL=NETASSIST
PORT=20000
Before and after the block there must be an empty line. You can also choose any other number for PORT, which specifies a UDP/IP port, which gets opened by TRACE32. (If more than one TRACE32 instance is active at the same time, use different a port number for each instance.)
If TRACE32 was started with open Remote-API port you can send a QUIT command to the still running application instead of terminating it via a kill-command. To send the QUIT command used command line tool t32rem.exe as follow:
t32rem localhost port=20000 QUIT
Finally we need a way to handle the (hopefully rarely happening) situation that TRACE32 somehow crashed and is not longer responsive. Then you have to kill it of course. For a proper reconnect use the following setting CONNECTIONMODE=AUTOCONNECT in the PBI= section of you TRACE32 config-file (by default this is c:\T32\config.t32). This setting does the "Reset device and connect" without asking you.
Putting all together you config-file should look somehow like that:
OS=
ID=myT32
SYS=C:\T32
PBI=
USB
CONNECTIONMODE=AUTOABORT
RCL=NETASSIST
PORT=20000

Related

debug port problem while running Lauterbach CMM script

Currently Im developing Lauterbach CMM scripts to automate test cases for SPC58NG84
As part of Test case:
- Need to reset target system before and after test case.
- Need to read and wrte variable values from C code.
When I run test scripts I got error 'debug port problem' and in 'watch window' all variable values showing BUS ERROR.
Can you please let me know how to debug this issue?.
What are the reasons causing 'debug port problem'?
Error Message in Area winodw:
CO:2 error: CPU suddenly left debug mode (OSR=0x3C1)
CO:0 JTAGID=0x11110041
Warning: CO:1 Core currently in reset. Stopping core on activation.
CMM Script:
Test Pre condition: Reset target
Break.Delete
WAIT 100.ms
SYStem.Mode Down
SYStem.DETECT.CPU
SYStem.Mode Up
B:: Go
WAIT 500.ms
Test case Execution:
--Read and write Variables in software-----
Test Post condition: Reset target
Break
Break.Delete
WAIT 100.ms
SYStem.Mode Down
SYStem.Mode Up
B:: Go
WAIT 1000.ms
The error 'debug port problem' after the Break command usually means that the target application crashed so badly that core does not respond to the debugger's halt command anymore.
In order to debug the problem, make sure that your boot loader sets up the interrupt vector start address (IVPR) as early as possible, and also put branch-to-self instructions to all interrupt handler addresses, unless interrupt handler code already exists.
Once this is done, set program preakpoints to the interrupt handlers typically involved in crashes: machine check, data storage, instruction storage, program interrupt. Doing so should catch the core when the crash occurs, and the SRR0 (CSRR or MCSRR, depending on interrupt type) will show you at which address the problem occurred.

C++ pause/resume system on large operation

I have a C++ program that loads a file with few millions lines and starts processing, the same operation was done by a php script, but in order to reduce the execution time I switched to C++.
In the old script, I checked whether there is a file with the current operation id in a "pause" folder, the file is empty It is just to check if a pause is requested, the script then checks after each 5 iterations if there is such file, if so It stuck on an empty loop until the file is deleted (a.k.a resume) :
foreach($lines as $line)
{
$isFinished = $index >= $countData - 1;
if($index % 5 == 0)
{
do
{
$isPaused = file_exists("/home/pauses/".$content->{'drop-id'});
}while($isPaused);
}
// Starts processing the line here
}
But since disk accessing is relatively slow, I don't want to follow the same approach, so I was thinking of some sort of commands that simulates this :
$ kill cpp_program // C++ program returns the last index checked e.g: 37710
$ ./main 37710
$ // cpp_program escapes the first 37709 lines and continues its job
What do you think of this approach ? Is-it feasible ? Is-it non time-consuming ? Is there any better approach ?
Thank you
Edit : A clarification because this seems a little ambiguous, this task runs in the background, there is another application which starts this one, I want to be able to send command from the management app (through Linux commands) to the background task to pause/resume.
Jumping to the 37710 line of a text file sadly requires reading all 37710 lines before it on most operating systems.
On most operating systems, text files are binary files with a convention about newlines. But the OS doesn't cache where the newlines are.
So to find the newlines, you have to read every byte.
If your program saved the byte offset of the file it had reached, it could seek to that location, however.
You can save the state of your program to some config file as you are shutting down, and set it to resume by default when it starts up again. This will require catching the signal you use to shut down, making your main logic notice the signal flag being set, and then cleanly shutting down. It is a very C-esque operation.
Now, a different traditional way to make a program controllable remotely is to have it listen on a TCP port (and/or stdin) and take command line commands there.
To go that way, you'd write a REPL component, then hook that up to whatever input and output.
Either you'd do the REPL in a coroutine like way between processing files, or you'd spawn a separate thread to do REPL and have it communicate asynchronously with the processing thread.
However, this could be beyond your skill. Each step of this (writing a REPL system, having it not block the main work, responding to commands, then attaching it to a TCP port) would take some effort and learning on your part.

Sending parameters through ssh. Are there NON-BLOCKING input functions?

I am working with an embedded system in which a Linux-based OS is running. Let's say that an application is running and the behavior needs to change when some actions happen. I did it using buttons and switches on the board but I have no idea on how to do it via ssh where the output of the application is constantly prompt. Any suggestion? Is it possible to use the keyboard of the laptop to send parameters at runtime only if a keyboard-button is pressed? (let's imagine I want to press only the + and the -). Of course, the output of the application should continue to be prompt constantly.
Of course the solution cin << will not work because it stops the execution until the new parameter is set up. The aim should be "change behavior if and only if + or - are pressed".
Use signals. Register a signal handler in your program and signal it from the outside with pkill -<SIGNAL> -f <PROGRAM> or kill -<SIGNAL> <PID>. For instance:
ssh user#server pkill -USR1 -f my_program

Applescript command encountering error after closing chrome window

So I have been working on a project to mess around with some of my coding friends. I am trying to make an AppleScript application that tells Chrome to go back a page when run and I want it to run all the time. I have had to base it off of whether or not chrome has an active window open or not, I managed to get it to work so far but when I put in the repeated "Go back" command it comes up with an error message saying can't get window 1.
This is the code I am using. I am using High Sierra if that makes a difference.
repeat
if application "Google Chrome" is running then
repeat
tell application "Google Chrome"
if exists (window 1 of application "Google Chrome") then
repeat while exists (window 1 of application "Google Chrome")
go back tab of window 1
end repeat
end if
end tell
end repeat
end if
end repeat
No. This is not how to implement a stay-open script. Doing endless repeat loops with no means of exiting them is just going to devour system resources and make Google Chrome unusable until the script is forced to quit.
Also, the code is horrific: lots of redundant statements and confusing syntax.
You would better achieve your aim by creating what is called a stay-open application script, which will use the idle handler to process commands every few seconds or so. As the name implies, the script will stay open and execute the commands until you tell it to quit.
Start by declaring a property that determines how often the idle handler is called. This is defined at the bottom, following a run handler, which executes upon running of the script and calls the idle handler.
property idleTime : 20 --seconds
on run
idle
end run
on idle
tell application "Google Chrome"
if it is not running then return idleTime
tell window 1 to if it exists then ¬
tell its active tab
if its URL contains "disney" then ¬
tell me to quit
set its URL to "chrome://newtab/"
end tell
end tell
return idleTime
end idle
I slightly modified the joke you're pulling on your friends, because go back will only work so many times before you reach the end of the history and there's no further back one can go. Instead, I told the tab to load up the New Tab starting page every 20 seconds, which I'm sure will be very confusing for the user.
In order to get it up and running properly, you need to save the script as an Application, and check the box that marks it as a stay open script. Then simply double click to run it.
There are two ways to terminate this script: ① Open Activity Monitor and terminate its process from the list of running processes; or ② Visit Disney.com (or any Disney website) in Chrome and wait 20 seconds.
Simply save this code as a stay open application.
on idle
tell application "Google Chrome"
if it is not running then return 10 -- seconds to wait before repeating
tell window 1 to if it exists then ¬
try
go back active tab
end try
end tell
return 10 -- seconds to wait before repeating
end idle

GenerateConsoleCtrlEvent() won't due for termination signaling to process run by cmd.exe

When one is interactively using cmd.exe to run all sort of windows CLI application, one can easily stop them by pressing CTRL+C or CTRL+BREAK . this is implemented by signaling the process as can be read here. As for cmd.exe itself, it does not terminate in these conditions as can be explained in a comment of this question.
Now, consider the following scenario. My application open a cmd.exe using CreateProcess(), and the user has started another application b.exe through it. Say that my application want to fold before b.exe has ended , and it doesn't really care about the graceful termination of it. optimally, I'd like to mimic the user pressing CTRL+C and then send exit to the cmd.exe (let's say I can do it IO-wise). the windows api offers GenerateConsoleCtrlEvent() for that (almost) exact purpose, but it can be ignored by the process (cmd.exe in that case) and in particular , it won't forward the signal to b.exe.