Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
Hello,
I want to dynamically Create a SYS/bios mailbox ,but I encounter a problem.The complete codes is as follows:
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Mailbox.h>
#include <ti/sysbios/knl/Event.h>
Event_Handle myEvent;
Task_Handle tsk1;
Task_Handle tsk2;
Mailbox_Handle mbox;
typedef struct{
UInt id;
Char buf[10];
} msg;
msg msgC,msgA,msgB;
/****************************************************************************/
/* */
/* delay */
/* */
/****************************************************************************/
Void Delay(UInt n)
{
UInt i;
for(i=n; i>0; i--);
}
void writerTask(void)
{
Mailbox_post(mbox, &msgA, BIOS_WAIT_FOREVER);
/* implicitly posts Event_Id_00 to myEvent */
}
void isr(void)
{
Event_post(myEvent, Event_Id_01);
}
void readerTask(void)
{
UInt events;
UChar i;
while (1) {/* Wait for either ISR or Mailbox message */
events = Event_pend(myEvent,
Event_Id_NONE, /* andMask = 0 */
Event_Id_00 + Event_Id_01, /* orMask */
BIOS_WAIT_FOREVER); /* timeout */
if (events & Event_Id_00) {
/* Get the posted message.
* Mailbox_pend() will not block since Event_pend()
* has guaranteed that a message is available.
* Notice that the special BIOS_NO_WAIT
* parameter tells Mailbox that Event_pend()
* was used to acquire the available message.
*/
Mailbox_pend(mbox, &msgB, BIOS_NO_WAIT);
System_printf ("The number of circulation is %d!\n", (msgB.id));
for(i=0;i<10;i++)
System_printf ("The number of circulation is %d!\n", (msgB.buf[i]));
}
if (events & Event_Id_01) {
System_printf("The event is ----Event_Id_01----!\n");
}
}
}
/****************************************************************************/
/* */
/* task */
/* */
/****************************************************************************/
Void TaskCore1(UArg a0, UArg a1)
{
UChar i;
System_printf("Enter TaskCore1()\n");
for(;;)
{
// System_printf("TaskCore1()休眠之前*********\n");
// Task_sleep(10);
// System_printf("TaskCore1()休眠之后刚启动*********\n");
// 循环
for(i=0;i<10;i++)
{
// 延时
System_printf ("The number of circulation is %d!\n", i);
System_flush();
Delay(0x002FFFFF);
Delay(0x002FFFFF);
if(i==1)
{
writerTask();
System_printf ("The Event_Id_00 is posted!\n");
}
if(i==5)
{
isr();
System_printf ("The Event_Id_01 is posted!\n");
}
}
}
}
Void TaskCore2(UArg a0, UArg a1)
{
for(;;)
{
System_printf("Enter TaskCore2()\n");
System_flush();
//////////////////////////////////////////
readerTask();
}
}
/****************************************************************************/
/* */
/* 主函数 */
/* */
/****************************************************************************/
Int main()
{
Mailbox_Params mboxParams;
Error_Block eb;
Error_init(&eb);
myEvent = Event_create(NULL, &eb);
if (myEvent == NULL) {
System_abort("Event create failed");
}
System_printf ("The myEvent set up successful!\n");
Mailbox_Params_init(&mboxParams);
mboxParams.readerEvent = myEvent;
/* Assign Event_Id_00 to Mailbox "not empty" event */
mboxParams.readerEventId = Event_Id_00;
mbox = Mailbox_create(sizeof(msg), 50, &mboxParams,NULL);
if (mbox == NULL) {
System_abort("Mailbox create failed");
}
System_printf ("The mboxParams set up successful!\n");
/* Mailbox_create() sets Mailbox's readerEvent to
* counting mode and initial count = 50 */
UChar aa;
(msgC.id)=100;
// circultaion
for(aa=0;aa<10;aa++)
msgC.buf[aa]=aa*aa;
msgA=msgC;
//create two tasks
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.priority = 1;
tsk1 = Task_create(TaskCore1, &taskParams, NULL);
Task_Params_init(&taskParams);
taskParams.priority = 2;
tsk2 = Task_create(TaskCore2, &taskParams, NULL);
// 启动 SYS/BIOS 系统
BIOS_start();
return(0);
}
I rewrite mmw_dss.c based on mmw_caputre demo.there is a error when compile. the errors as follows:
Undefined reference to 'ti_sysbios_knl_Mailbox_Params__init__S' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem
Undefined reference to 'ti_sysbios_knl_Mailbox_pend__E' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem
Undefined reference to 'ti_sysbios_knl_Mailbox_post__E' in file ./dss_main.oe674 .xdchelp /mmw_dss C/C++ Problem
when I add the content (var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');) to the dss_mmw.cfg file,the project compile successfully.When debugging ,it encounters the problems as follows:
[C674X_0] The myEvent set up successful!
{module#35}: line 78: error {id:0x10000, args:[0x804a1d, 0x804a1c]}
xdc.runtime.Error.raise: terminating execution
can you help me,thanks very much!