I have a simple C code which will update static variable with floating variable. Let's say I have
static float32 totalcount = 60.73f;
I want to know how to get float values from Lauterbach trace32
. I have tried to print the float
values using below t32api64.dll
and ctype
method.
error = ctypes.c_int32(0)
result = ctypes.c_float32(0)
t32api.T32_Cmd (b"InterCom mycore Var totalcount")
error = t32api.T32_EvalGet(ctypes.byref(result));
if (error == 0):
print("OK");
print (result.value)
else:
print("Nok error")
But I am getting some different ouputt.
Output:
$ python test.py
OK
8.96831017167883e-44
After some research, I understood that t32api.T32_EvalGet()
function is not supporting float
values. So I would like to know how to print the float values from trace32
using python. Please suggest some method to print float values?
You can either use T32_ExecuteFunction_Double()
or T32_EvalGetString()
:
Example for int T32_ExecuteFunction_Double(const char *pExpression, char *pBuffer, uint32_t BufferSize, double *pResult)
error = ctypes.c_int32(0)
buffer = (ctypes.c_char * 4096)()
result = ctypes.c_double(0)
error = t32api.T32_ExecuteFunction_Double(b'Var.FVALUE("totalcount")', buffer, len(buffer), ctypes.byref(result)))
print('Var.FVALUE("totalcount"):', result.value)
Example for int T32_ReadVariableString(const char *symbol, char *string, int maxlen)
error = ctypes.c_int32(0)
buffer = (ctypes.c_char * 4096)()
error = t32api.T32_Cmd(b"Eval Var.STRing(totalcount)")
if error == 0:
error = t32api.T32_EvalGetString(buffer, len(buffer))
if error == 0:
print(b"Eval Var.STRing(totalcount):", float(buffer.value))
Example using the pyrcl package:
import lauterbach.trace32.rcl as t32
with t32.connect() as dbg:
variable = dbg.variable.read("totalcount")
print(variable.value)
# or
variable = dbg.fnc("Var.FVALUE(totalcount)")
print(variable)