📄 test.c
字号:
////这份代码主要是测试了接口函数不使用任务函数实现的情况下,只是定时地等待实现具体功能
////的任务函数对某些全局变量的修改之后,程序仍然能达到想达到的目的;在程序中,使用全局变量
////做为协议栈的接口函数和实现具体功能的任务函数之间的通信方式
//#include <includes.h>
//
//
//
//#define TASK_STK_SIZE 128
//#define TASK_START_PRIO 5
//
//
//
//typedef struct{
//
// INT8U para1;
// INT8U para2;
//}TEST_PARAMETERS;
//TEST_PARAMETERS testParameters;
//
//OS_STK AppStartTaskStk[TASK_STK_SIZE];
//OS_STK taskScanTaskStk[TASK_STK_SIZE];
//
//OS_STK testATaskStk[TASK_STK_SIZE];
//OS_STK testBTaskStk[TASK_STK_SIZE];
//
//OS_STK funATaskStk[TASK_STK_SIZE];
//OS_STK funBTaskStk[TASK_STK_SIZE];
//
//OS_STK wrapFunATaskStk[TASK_STK_SIZE];
//INT16S key;//用于退出的键
//char * s;
//INT8U err;
//char *ss;
//
//
//
//static void AppStartTask(void *p_arg);
//
//static void taskScan(void *p_arg);
//
//
//void testA(void *pTaskNum);
//void testB(void *pTaskNum);
////void funA(void *pTaskNum);
//INT8U funA(INT8U para1,INT8U para2);
////void funA();
//int funB();
////void funB(void *pTaskNum);
//
//
////void wrapNlmeFormNetworkTask(void *pTaskNum);
////void mlmeScanEmulation(void *pTaskNum);
////void nwkFormProcedure();
////void mscScanProcedureEmulation();
//INT8U scanStatus=0;
//
//void wrapFunA(void *pTaskNum);
//void wrapFunB(void *pTaskNum);
//
//volatile int testVariable=0;
//BOOLEAN testAReturn;
//BOOLEAN testBReturn;
//
//// 信号量句柄
//OS_EVENT *scanStatusSem=NULL;
//OS_EVENT *returnValueFromFunBSem=NULL;
//
//OS_EVENT *scanMessageBox=NULL;
//OS_EVENT *formNetworkMessageBox=NULL;
//OS_EVENT *scanReturnMessageBox=NULL;
//OS_EVENT *commonMessageBox=NULL;
//
//
//
//
//volatile int returnValueOfFunB=100;
//volatile int testValue;
//
//#if OS_VIEW_MODULE > 0
//static void AppTerminalRx(INT8U rx_data);
//#endif
//
//
//
//void main(int argc, char *argv[])
//{
// INT8U err;
//
//
//#if 0
// BSP_IntDisAll(); /* For an embedded target, disable all interrupts until we are ready to accept them */
//#endif
//
// OSInit(); /* Initialize "uC/OS-II, The Real-Time Kernel" */
// OSTaskCreateExt(AppStartTask,
// (void *)0,
// (OS_STK *)&AppStartTaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO,
// TASK_START_PRIO,
// (OS_STK *)&AppStartTaskStk[0],
// TASK_STK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
//
//
//#if OS_TASK_NAME_SIZE > 11
// OSTaskNameSet(APP_TASK_START_PRIO, (INT8U *)"Start Task", &err);
//#endif
//
//#if OS_TASK_NAME_SIZE > 14
// OSTaskNameSet(OS_IDLE_PRIO, (INT8U *)"uC/OS-II Idle", &err);
//#endif
//
//#if (OS_TASK_NAME_SIZE > 14) && (OS_TASK_STAT_EN > 0)
// OSTaskNameSet(OS_STAT_PRIO, "uC/OS-II Stat", &err);
//#endif
// OSStart(); /* Start multitasking (i.e. give control to uC/OS-II) */
//}
///*$PAGE*/
///*
//*********************************************************************************************************
//* STARTUP TASK
//*
//* Description : This is an example of a startup task. As mentioned in the book's text, you MUST
//* initialize the ticker only once multitasking has started.
//* Arguments : p_arg is the argument passed to 'AppStartTask()' by 'OSTaskCreate()'.
//* Notes : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
//* used. The compiler should not generate any code for this statement.
//* 2) Interrupts are enabled once the task start because the I-bit of the CCR register was
//* set to 0 by 'OSTaskCreate()'.
//*********************************************************************************************************
//*/
//
//void AppStartTask (void *p_arg)
//{
// p_arg = p_arg;
//
//#if 0
// BSP_Init(); /* For embedded targets, initialize BSP functions */
//#endif
//
//
//#if OS_TASK_STAT_EN > 0
// OSStatInit(); /* Determine CPU capacity */
//#endif
// //OSTaskCreateExt(nlmeFormNetEmulation,
// // (void *)&testParameters, //this is the parameter
// // (OS_STK *)&funATaskStk[TASK_STK_SIZE-1],
// // TASK_START_PRIO+7,
// // TASK_START_PRIO+7,
// // (OS_STK *)&funATaskStk[0],
// // TASK_STK_SIZE,
// // (void *)0,
// // OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// OSTaskCreateExt(wrapFunA,
// (void *)&testParameters, //this is the parameter
// (OS_STK *)&wrapFunATaskStk[TASK_STK_SIZE-1],
// TASK_START_PRIO+7,
// TASK_START_PRIO+7,
// (OS_STK *)&wrapFunATaskStk[0],
// TASK_STK_SIZE,
// (void *)0,
// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
// for(;;)
// {
// //如果按下esc键,则退出ucOS
// if(PC_GetKey(&key)==TRUE)
// {
// if(key==0x1B)
// {
// PC_DOSReturn();
// }
// }
// //OS_Printf("Delay 1 second and print\n");
// OSTimeDlyHMSM(0,0,3,0);
// }
//}
//
//
////void nlmeFormNetEmulation(void *pTaskNum)
////{
//// UINT8 testANum;
//// DWORD rc;
//// INT8U err;
//// printf("nlmeFormNetEmulation starts!\n");
//// //请求组网消息邮箱
//// for(;;)
//// {
//// /// ss=OSMboxPend(formNetworkMessageBox,10,&err);
//// nwkFormProcedure();
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
//// break;
//// else
//// {
//// OSTimeDlyHMSM(0,0,1,0);
//// continue;
//// }
//// }
//// printf("nlmeFormNetEmulation end!\n");
//// OSTaskDel(TASK_START_PRIO+6);
//// OSTaskDel(TASK_START_PRIO+7);
////}
////
////void nwkFormProcedure()
////{
////
//// OSTaskCreateExt(mlmeScanEmulation,
//// (void *)0, //this is the parameter
//// (OS_STK *)&funBTaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+6,
//// TASK_START_PRIO+6,
//// (OS_STK *)&funBTaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
//// printf("\nnwkFormProcedure!\n");
////
////}
////
////void mlmeScanEmulation(void *pTaskNum)
////{
//// printf("mlmeScanEmulation starts!\n");
//// mscScanProcedureEmulation();
//// for(;;)
//// {
//// //mscScanProcedureEmulation();
//// printf("mlmeScanEmulation completes");
//// OSMboxPost(commonMessageBox,&scanStatus);
//// OSTimeDlyHMSM(0,0,1,0);
//// //OSTaskDel(TASK_START_PRIO+6);
//// }
////
////}
////
////// scanMessageBox=OSMboxCreate((void *)0); //创建信道扫描消息邮箱
//////formNetworkMessageBox=OSMboxCreate((void *)0); //创建组网消息邮箱
//////scanReturnMessageBox=OSMboxCreate((void *)0); //创建扫描函数和组网任务函数之间进行通信的邮箱
////// //commonMessageBox=OSMboxCreate((void *)0); //创建公共消息邮箱,负责在所有的任务之间进行通信
//////testParameters.para1=1;
//////testParameters.para2=2;
////
////void mscScanProcedureEmulation()
////{
////
//// scanStatus=1;
//// printf("mscScanProcedureEmulation completes!\n");
//// //OSMboxPost(formNetworkMessageBox,&scanStatus);
////}
//
//
////
////void testA(void *pTaskNum) //emulates nwkFormNetworkProcedure
////{
//// BYTE i;
//// INT8U err;
//// OS_Printf("testA!\n");
//// // returnValueOfFunB=funB();
//// OSTaskCreateExt(funB,
//// (void *)0,
//// (OS_STK *)&funBTaskStk[TASK_STK_SIZE-1],
//// TASK_START_PRIO+4,
//// TASK_START_PRIO+4,
//// (OS_STK *)&funBTaskStk[0],
//// TASK_STK_SIZE,
//// (void *)0,
//// OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
////
////
////
//// //请求组网消息邮箱
//// for(;;)
//// {
//// ///ss=OSMboxPend(scanReturnMessageBox,10,&err);
//// ss=OSMboxPend(commonMessageBox,10,&err);
//// if(err==OS_NO_ERR)
//// {
//// printf("testA completes!\n");
//// s='c';
//// OSMboxPost(commonMessageBox,s);
////
//// OSTimeDlyHMSM(0,0,1,0);
//// break;
//// }
//// else
//// {
//// OSTimeDlyHMSM(0,0,1,0);
//// printf("No message in scanReturnMessageBox!\n");
//// continue;
//// }
//// }
//// ///OSMboxPost(formNetworkMessageBox,s);
////
//// OSTaskDel(TASK_START_PRIO+5);
//// printf("here?");
////
////
////}
////
////
////void testB(void *pTaskNum)
////{
//// BYTE i;
//// INT8U err;
//// printf("testB starts!\n");
//// for(;;)
//// {
//// testVariable=1;
//// //sprintf(s,"%d",testVariable);
//// //s='s';
//// ///OSMboxPost(scanMessageBox,&testVariable);
//// 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!
////}
////
////
////
//////void funA() //emulate nlmeFormNetworkRequest
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -