This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

question about printf in DSP side

hi TI-friends,

   I want to clarify the difference between Vps_printf and Vps_rprintf. But I can't get any idea although I got the following. Could you explain this for us?

int Vps_printf(char *format, ...)
{
int retVal;
va_list vaArgPtr;
char *buf = NULL;
UInt32 cookie;

cookie = Hwi_disable();

buf = &gRemoteDebug_serverObj.printBuf[0];

va_start(vaArgPtr, format);
vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN, format, vaArgPtr);
va_end(vaArgPtr);

retVal = RemoteDebug_serverPutString(gRemoteDebug_serverObj.coreId, buf);

Hwi_restore(cookie);

if (BIOS_getThreadType() == BIOS_ThreadType_Task)   => here're difference. but what's the meaning??
{
/* Printf should be called only from Task context as it does pend.
* Calling from other context will cause exception
*/
System_printf(buf);
}

return (retVal);
}

int Vps_rprintf(char *format, ...)
{
int retVal;
va_list vaArgPtr;
char *buf = NULL;
UInt32 cookie;

cookie = Hwi_disable();

buf = &gRemoteDebug_serverObj.printBuf[0];

va_start(vaArgPtr, format);
vsnprintf(buf, REMOTE_DEBUG_SERVER_PRINT_BUF_LEN, format, vaArgPtr);
va_end(vaArgPtr);

retVal = RemoteDebug_serverPutString(gRemoteDebug_serverObj.coreId, buf);

Hwi_restore(cookie);

return (retVal);
}

  • Vps_printf will print on stdout and also to shared memory log buffer.

        - When you CCS+JTAG emulator connected to target print to stdout will appear on CCS console window

    Vps_rprintf will print only to shared memory log buffer.

    The portion of code marked is bold is clearly mentioned in the comment.

    print to stdout (System_printf) will acquire a mutex lock and hence can be called only from Task context and not SWI or HWI context.