📄 test.c
字号:
////void funA(void *pTaskNum)
////{
//// UINT8 testANum;
//// DWORD rc;
//// INT8U err;
//// //UINT8 returnFromfunB=0;
////
//// printf("funA starts!\n");
////
//// OSTaskCreateExt(testA,
//// (void *)0,
//// (OS_STK *)&testATaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+5,
//// TASK_START_PRIO+5,
//// (OS_STK *)&testATaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
////
////
////
//////this function should communicate with the task testA
////
////////The following code :funA is normal interface function,and use semaphore to communicate with testA;
////
//// //do{
//// // OSSemPend (returnValueFromFunBSem,0, &err);
//// // if(err!=OS_NO_ERR)
//// // {
//// // //doesn't get semaphore
//// // printf("funA haven't get semaphore!\n");
//// // //ReleaseSemaphore(scanStatusSem, 1, NULL);
//// // OSTimeDlyHMSM(0, 0, 1, 0);
//// // //Sleep(1000);
////
//// // }
//// // else
//// // {
//// // //get semaphore
//// // printf("funA get semaphore!\n");
//// // //testVariable=1;
//// // if(returnValueOfFunB!=100)
//// // {
//// //
//// // OS_Printf("testVariable have been modified by testB,now,its value is %d!\n",testVariable);
//// // OS_Printf("testA have returned from funB,now,returnValueOfFunB value is %d!\n",returnValueOfFunB);
//// // OS_Printf("nlmeFormnetworkRequest ended!\n");
//// // OSSemPost(returnValueFromFunBSem);
//// //
//// // OSTaskDel(TASK_START_PRIO+20);//delete testA task!
//// // break;
//// // }
//// // else
//// // {
//// // //Sleep(2000);
//// // OSTimeDlyHMSM(0, 0, 1, 0);
//// // OSSemPost(returnValueFromFunBSem);
//// // //Sleep(2000);
//// // }
//// // }
//// //}while(TRUE);
////
////
//// //请求组网消息邮箱
//// for(;;)
//// {
//// /// ss=OSMboxPend(formNetworkMessageBox,10,&err);
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
////
//// break;
//// else
//// {
//// OSTimeDlyHMSM(0,0,1,0);
//// continue;
//// }
//// }
////
//// printf("funA end!\n");
////
////
////////The following code :funA is task function,and use semaphore to communicate with testA;
//// //while(TRUE)
//// //{
//// // OS_Printf("funA executed!\n");
//// // do{
////
//// // if(testAReturn==TRUE) //testAReturn is also a semaphore!
//// // {
//// // OS_Printf("testVariable have been modified by testB,now,its value is %d!\n",testVariable);
//// // OS_Printf("testA have returned from funB,now,returnValueOfFunB value is %d!\n",returnValueOfFunB);
//// // OS_Printf("nlmeFormnetworkRequest ended!\n");
//// // OSTaskDel(TASK_START_PRIO+2);//delete testA task!
//// // OSTaskDel(TASK_START_PRIO+4);
//// // break;
//// // }
//// // else
//// // continue;
//// // }while(TRUE);
//// // OSTimeDlyHMSM(0, 0, 1, 0);
//// // //Sleep(2000);
//// //}
////}
////
////void funB(void *pTaskNum) //emulate mlmeScanRequest
////{
//// UINT8 testBNum;
//// INT8U err;
////
//// printf("funB starts!\n");
//// OSTaskCreateExt(testB,
//// (void *)0,
//// (OS_STK *)&testBTaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+3,
//// TASK_START_PRIO+3,
//// (OS_STK *)&testBTaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
//// //OS_Printf("In funB,testVariable is %d!\n",testVariable);
//// //do{
//// // OSSemPend (scanStatusSem,0, &err);
//// // if(err!=OS_NO_ERR)
//// // {
//// // OS_Printf("funB haven't get semaphore!\n");
//// // // ReleaseSemaphore(scanStatusSem, 1, NULL); //should be removed !
//// // //Sleep(6000);
//// // OSTimeDlyHMSM(0, 0, 1, 0);
////
//// // }
//// // else
//// // {
//// // //get semaphore
//// // OS_Printf("funB get semaphore!\n");
//// // if(testVariable==0) //emulate mscInfo.status==MSC_SCAN_ACTIVE
//// // {
//// // //Sleep(1000);
//// //
//// // OS_Printf("the value haven't been modified!\n");
//// // OSTimeDlyHMSM(0, 0, 1, 0);
//// // OSSemPost(scanStatusSem);
//// // }
//// // else
//// // {
//// // OS_Printf("I am success!\n");
//// // // 释放信号量计数
//// //
//// // OSTaskDel(TASK_START_PRIO+3);
//// // OSSemPost(scanStatusSem);
//// // break;
//// // }
//// // }
//// //}while(TRUE);
////
////
//// //do{
////
//// // if(testBReturn==FALSE)
//// // {
//// // OS_Printf("testB is not end!\n");
//// // Sleep(1000);
//// // }
//// // else
//// // {
//// // OS_Printf("testB completes!\n");
//// // return testVariable;
////
//// // }
//// //}while(TRUE);
////
//// //请求信道扫描消息邮箱
//// for(;;)
//// {
//// ///ss=OSMboxPend(scanMessageBox,10,&err);
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
//// {
//// printf("funB end!\n");
//// ///OSMboxPost(scanReturnMessageBox,&returnValueOfFunB);
//// OSMboxPost(commonMessageBox,&returnValueOfFunB);
//// OSTimeDlyHMSM(0,0,1,0);
//// break;
//// }
//// else
//// {
//// printf("No message in scanMessageBox!\n");
//// OSTimeDlyHMSM(0,0,1,0);
//// continue;
//// }
////
//// }
////
////
//// //OSTaskDel(TASK_START_PRIO+6);
//// OSTimeDlyHMSM(0,0,1,0);
//// printf("funB deletes!\n");
//// //OSTimeDlyHMSM(0,0,1,0);
//// //printf("funB end!\n");
//// //return testVariable;
////}
//
//
//void wrapFunA(void *pTaskNum)
//{
// INT8U result;
// pTaskNum=pTaskNum;
// result=funA(testParameters.para1,testParameters.para2);
// OS_Printf("funA() completes!\n");
// OS_Printf("the result is %d\n",testValue);
// while(TRUE)
// {
// OSTimeDlyHMSM(0,0,1,0);
// OSTaskDel(TASK_START_PRIO+4);
// }
//}
//
//INT8U funA(INT8U param1,INT8U param2)
//{
// printf("funA starts!\n");
// OSTaskCreateExt(testA,
// (void *)0,
// (OS_STK *)&testATaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO+5,
// TASK_START_PRIO+5,
// (OS_STK *)&testATaskStk[0],
// TASK_STK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// //should wait some semaphore post by testA;
// for(;;)
// {
// if(returnValueOfFunB==1)
// {
// OSTaskDel(TASK_START_PRIO+5);
// break;
// }
// else
// {
// Sleep(2000);
// continue;
// }
// }
// printf("funA end!\n");
// return param1+param2;
//
//}
//
//
//void testA(void *pTaskNum) //emulates nwkFormNetworkProcedure
//{
// BYTE i;
// INT8U err;
// OS_Printf("testA!\n");
// returnValueOfFunB=funB();
// testValue=returnValueOfFunB+funB();
// for(;;)
// {
// if(returnValueOfFunB==1)
// {
//
// break;
// }
// else
// {
// OSTimeDlyHMSM(0,0,1,0);
// continue;
// }
//
// }
// ///OSMboxPost(formNetworkMessageBox,s);
// printf("testA end!\n");
//
// //OSTimeDlyHMSM(0,0,1,0);
//
//}
//
//int funB()
//{
//
// printf("funB starts!\n");
// OSTaskCreateExt(testB,
// (void *)0,
// (OS_STK *)&testBTaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO+3,
// TASK_START_PRIO+3,
// (OS_STK *)&testBTaskStk[0],
// TASK_STK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// for(;;)
// {
// if(testVariable==1)
// break;
// else
// {
// Sleep(2000);
// continue;
// }
// }
// OSTaskDel(TASK_START_PRIO+3);
// printf("funB end!\n");
// return testVariable;
// //should wait some semaphore post by testB
//}
//
//void testB(void *pTaskNum)
//{
// BYTE i;
// INT8U err;
// printf("testB starts!\n");
// for(;;)
// {
// testVariable=1;
// // OSMboxPost(commonMessageBox,&testVariable);
// printf("testB completes!\n");
// //OSTimeDlyHMSM(0,0,1,0);
// break;
// }
// OSTimeDlyHMSM(0,0,1,0);
// //OSTaskDel(TASK_START_PRIO+3); //TASK_START_PRIO+3 is the task testB's prority!
//}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -