2024-11-13 01:33 AM
Hi,
i want to monitor the following statement (the value of p_Payload[]) during debugging process in the Live Expression Window of CubeIDE:
if(p_Notification->DataTransfered.p_Payload[0] == 0x02)
I added the following statement to the Live Expression Window
and tried a few other variations, but without succes.
Can somebody help?
Solved! Go to Solution.
2024-11-14 06:26 AM
Hello @ledi7
Live Expressions can only evaluate variables that are currently in scope. p_Notification
is a local variable of a function that has exited
void OTA_Notification(OTA_NotificationEvt_t *p_Notification);
its memory may no longer be valid, leading to evaluation failures. Ensure you are trying to access the variable while still within the function where it is defined.
or consider using global variables for debugging purposes, as they tend to be more stable in Live Expressions
2024-11-13 01:50 AM
Hello @ledi7
To monitor the actual values in p_Payload , you should use the correct syntax based on what you want to see:
To see the first element of the payload:
p_Notification->DataTransfered.p_Payload[0]
To see the entire array (if you know its size), you can use:
p_Notification->DataTransfered.p_Payload[0] // for first element
p_Notification->DataTransfered.p_Payload[1] // for second element, etc.
If you want to dereference and see a single value:
*(p_Notification->DataTransfered.p_Payload)
2024-11-13 02:02 AM
Hello @Ghofrane GSOURI ,
thank's for your reply. That works in "Expression Window"
but not in "Live Expression Window" as you can see here:
2024-11-13 02:16 AM
2024-11-13 03:14 AM
Hello @Ghofrane GSOURI
as mentioned in the post you suggested, i changed debugging and optimization level for the compiler.I tried to set the optimization level in the Build Settings to level "Optimize for Debug (-Og)" and "None (-O0)".
Then i removed and re-added the entries in the "Live Expression Window". But nothing has changed, same result as bevore.
I am working with CubeIDE1.16.1 and using the BLE example "BLE_p2pServer_ota" with the NUCLEO-WBA55 board. Here, most of .c and .h files from the firmware package are linked. Could this triggers the issue?
2024-11-14 05:21 AM
Hello @ledi7
Could you please verify that the Live Expressions is enabled in your configuration.
To do that please follow those steps:
1- right-clicking on your project in the Project Explorer and selecting Debug as-->1 STM32 C/C++ application
Go to Debugger and make sure that the live expression option is tick then press OK
.
2024-11-14 05:38 AM
Hello @Ghofrane GSOURI
yes, live expression is activated.
And for example, the variable "ledState" which is defined as "extern uint8_t ledState = 0;" is working in the Live Expressions window:
2024-11-14 06:26 AM
Hello @ledi7
Live Expressions can only evaluate variables that are currently in scope. p_Notification
is a local variable of a function that has exited
void OTA_Notification(OTA_NotificationEvt_t *p_Notification);
its memory may no longer be valid, leading to evaluation failures. Ensure you are trying to access the variable while still within the function where it is defined.
or consider using global variables for debugging purposes, as they tend to be more stable in Live Expressions