Add watch expression bug in cooperative multitasking

I’m used RCM5600W Development kit, with DC 10.56.

I tried add watch expression in cooperative multitasking with press CTRL+W on buffer variable when debugging then I get message “buffer is out of scope/not declared.” Its bug?

Part of code:


scofunc int handshake(unsigned char deviceId, unsigned char data) {
   unsigned char buffer[8];
   
   sprintf (buffer, "%c%c%c%c%c%02X%c", STX, deviceId, SELECTING, _ZERO, _ZERO, data, ETX);
}

It’s not really a bug.

Because buffer is a local stack based variable it is only in scope if you hit a breakpoint in that function and you cannot see it with a watch at any other time.

You could define it outside the function to make it non transient and set a watch on it then.

Regards,
Peter

1 Like

Thank you sir. One question again, if the variables declared inside the cooperative multitask function(stack), automatically be static?

I’ve never used the cofunction/costate mechanism for multitasking with Dynamic C and have used uCOS || instead. Briefly looking at the manual, it seems the variables in a cofunction are similar but not identical to static variables with a storage class of instance. The main difference as far as I can see comes into play if the cofunction is an indexed one. I think the visibility on these for watch purposes is still only really within the given cofunction.

Regards,
Peter