Other Parts Discussed in Thread: SYSBIOS
hi all,
I am developing on a EVMK2H board using the latest MSCSDK and SYSBIOS on the dsp cores. I am using CCSv6.1 I. was able to get System_printf to output text on the cole in the main function. I created a task dynamically in the main. However, the System_printf failed to output anything on the console from the task function that I created. The System_printf also failed during the subsequent call of another utility function from the task function.
I attached my codes down below.
/*
* ======== main.c ========
*/
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <xdc/runtime/Log.h>
#include <ti/sysbios/knl/Task.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Error.h>
// ipc headers
#include <ti/ipc/Ipc.h>
#include <ti/sdo/utils/MultiProc.h>
//#include <ti/sdo/ipc/MessageQ.h>
//#include <ti/ipc/SharedRegion.h>
#include <ti/ipc/MessageQ.h>
#include <ti/ipc/SharedRegion.h>
#include "msg.h"
#define Heap_ID 2
#define size = sizeof(MessageQ_MsgHeader) + 5
/*
* ======== taskFxn ========
*/
Void taskFxn();
Void msgWriter();
Void msgReader();
/*
* ======== main ========
*/
Int main()
{
/*
* use ROV->SysMin to view the characters in the circular buffer
*/
System_printf("enter main()\n");
//UInt16 CORE_ID = MultiProc_self();
Error_Block eb;
Task_Params taskParams;
System_printf("enter main()\n");
Task_Params_init(&taskParams);
taskParams.instance->name = "taskFxn";
taskParams.stackSize = 0x1000;
Error_init(&eb);
Task_create(taskFxn, &taskParams, &eb);
if (Error_check(&eb)) {
System_abort("main: failed to create application thread");
}
BIOS_start(); /* does not return */
return(0);
}
Void taskFxn()
{ System_printf("enter task function"); //this one failed to display anything on the console
UInt16 coreID = MultiProc_self();
if (coreID == (UInt16)1)
{
msgWriter();
}
else{
msgReader();
}
}
Void msgWriter(Void) {
System_printf("enter writer function"); //this one failed to display anything on the console
Int status = Ipc_start();
if (status < 0) {
System_abort("Ipc_start failed\n");
}
System_printf("IPC ready");
/*
do {
UInt16 id = MultiProc_getId("CORE1");
status = Ipc_attach(id);
} while (status == Ipc_E_NOTREADY);
*/
// allocate a message
Ptr heap;
heap = SharedRegion_getHeap(0);
MessageQ_registerHeap(heap,Heap_ID);
app_msg *msg;
MessageQ_QueueId qid;
do {
status =MessageQ_open("myQ",&qid);
} while (status == MessageQ_E_NOTFOUND );
System_printf("messageQ opened succesfully");
while (1)
{
msg = (app_msg * ) MessageQ_alloc(Heap_ID,sizeof(app_msg));
char payload[] ="hello";
(*msg).msg = payload;
MessageQ_put (qid, (MessageQ_Msg) msg);
}
}
Void msgReader (Void) {
System_printf("enter reader function"); //this one failed to display anything on the console
Int status = Ipc_start();
if (status < 0) {
System_abort("Ipc_start failed\n");
}
System_printf( "App_taskFxn: ipc ready");
/*
do {
UInt16 id =MultiProc_getId("CORE1");
status = Ipc_attach(id);
} while (status == Ipc_E_NOTREADY );
System_printf("ipc to dsp core 1 ready ");
*/
Ptr heap = SharedRegion_getHeap(0);
MessageQ_Handle que;
app_msg *msg;
MessageQ_registerHeap(heap,Heap_ID);
que = MessageQ_create("myQ", NULL);
while(1)
{
MessageQ_get(que,(MessageQ_Msg *)&msg,MessageQ_FOREVER);
char *payload = msg->msg;
System_printf("the payload is %s\n",payload);
MessageQ_free((MessageQ_Msg) msg);
}
}