提交 4a54de06 编写于 作者: W wusongqing

updated printf information in md files

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 acdfa44c
......@@ -121,7 +121,7 @@ VOID SendEntry(VOID)
ret = LOS_QueueWriteCopy(g_queue, abuf, len, 0);
if(ret != LOS_OK) {
printf("send message failure, error: %x\n", ret);
printf("Failed to send the message. Error: %x\n", ret);
}
}
......@@ -133,22 +133,22 @@ VOID RecvEntry(VOID)
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
if(ret != LOS_OK) {
printf("recv message failure, error: %x\n", ret);
printf("Failed to receive the message. Error: %x\n", ret);
}
printf("recv message: %s\n", readBuf);
printf("Message received: %s\n", readBuf);
ret = LOS_QueueDelete(g_queue);
if(ret != LOS_OK) {
printf("delete the queue failure, error: %x\n", ret);
printf("Failed to delete the queue. Error: %x\n", ret);
}
printf("delete the queue success.\n");
printf("Queue deleted.\n");
}
UINT32 ExampleQueue(VOID)
{
printf("start queue example.\n");
printf("Start queue example.\n");
UINT32 ret = 0;
UINT32 task1, task2;
TSK_INIT_PARAM_S initParam = {0};
......@@ -161,7 +161,7 @@ UINT32 ExampleQueue(VOID)
LOS_TaskLock();
ret = LOS_TaskCreate(&task1, &initParam);
if(ret != LOS_OK) {
printf("create task1 failed, error: %x\n", ret);
printf("Failed to create task1. Error: %x\n", ret);
return ret;
}
......@@ -170,16 +170,16 @@ UINT32 ExampleQueue(VOID)
initParam.usTaskPrio = 10;
ret = LOS_TaskCreate(&task2, &initParam);
if(ret != LOS_OK) {
printf("create task2 failed, error: %x\n", ret);
printf("Failed to create task2. Error: %x\n", ret);
return ret;
}
ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
if(ret != LOS_OK) {
printf("create queue failure, error: %x\n", ret);
printf("Failed to create the queue. Error: %x\n", ret);
}
printf("create the queue success.\n");
printf("Queue created.\n");
LOS_TaskUnlock();
return ret;
}
......@@ -190,9 +190,9 @@ UINT32 ExampleQueue(VOID)
The development is successful if the return result is as follows:
```
start queue example.
create the queue success.
recv message: test message.
delete the queue success.
Start queue example.
Queue created.
Message received: test message.
Queue deleted.
```
......@@ -187,30 +187,30 @@ VOID Example_DynMem(VOID)
/* Initialize the memory pool. */
ret = LOS_MemInit(g_testPool, TEST_POOL_SIZE);
if (LOS_OK == ret) {
printf("Mem init success!\n");
printf("Memory pool initialized.\n");
} else {
printf("Mem init failed!\n");
printf("Memory pool initialization failed.\n");
return;
}
/* Allocate memory.*/
mem = (UINT32 *)LOS_MemAlloc(g_testPool, 4);
if (NULL == mem) {
printf("Mem alloc failed!\n");
printf("Memory allocation failed.\n");
return;
}
printf("Mem alloc success!\n");
printf("Memory allocated.\n");
/* Assign a value.*/
*mem = 828;
printf("*mem = %d\n", *mem);
printf("*Memory = %d\n", *mem);
/* Release memory.*/
ret = LOS_MemFree(g_testPool, mem);
if (LOS_OK == ret) {
printf("Mem free success!\n");
printf("Memory released.\n");
} else {
printf("Mem free failed!\n");
printf("Memory release failed.\n");
}
return;
......@@ -222,9 +222,9 @@ VOID Example_DynMem(VOID)
The output is as follows:
```
Mem init success!
Mem alloc success!
*mem = 828
Mem free success!
Memory pool initialized.
Memory allocated.
*Memory = 828
Memory released.
```
......@@ -116,7 +116,7 @@ void Timer1_Callback(UINT32 arg) // Callback function 1
{
UINT32 tick_last1;
g_timerCount1++;
tick_last1 = (UINT32)LOS_TickCountGet(); //Obtain the current number of ticks.
tick_last1 = (UINT32)LOS_TickCountGet(); // Obtain the current number of ticks.
printf("g_timerCount1=%d, tick_last1=%d\n", g_timerCount1, tick_last1);
}
......@@ -140,29 +140,29 @@ void Timer_example(void)
/* Create a periodic software timer and execute callback function 2 every 100 ticks. */
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
printf("create Timer1 success\n");
printf("Timer 1 created.\n");
LOS_SwtmrStart(id1); // Start the one-shot software timer.
printf("start Timer1 success\n");
printf("Timer 1 started.\n");
LOS_TaskDelay(200); // Delay 200 ticks.
LOS_SwtmrTimeGet(id1, &tickCount); // Obtain the number of remaining ticks of the one-short software timer.
printf("tickCount=%d\n", tickCount);
LOS_SwtmrStop(id1); // Stop the software timer.
printf("stop Timer1 success\n");
printf("Timer 1 stopped.\n");
LOS_SwtmrStart(id1);
LOS_TaskDelay(1000);
LOS_SwtmrStart(id2); // Start the periodic software timer.
printf("start Timer2\n");
printf("Timer 2 started.\n");
LOS_TaskDelay(1000);
LOS_SwtmrStop(id2);
ret = LOS_SwtmrDelete(id2); // Delete the software timer.
if (ret == LOS_OK) {
printf("delete Timer2 success\n");
printf("Timer 2 deleted.\n");
}
}
......@@ -182,7 +182,7 @@ UINT32 Example_TaskEntry(VOID)
task1.usTaskPrio = 5;
ret = LOS_TaskCreate(&g_testTaskId01, &task1);
if (ret != LOS_OK) {
printf("TimerTsk create failed.\n");
printf("Failed to create the timer task.\n");
return LOS_NOK;
}
......@@ -198,12 +198,12 @@ UINT32 Example_TaskEntry(VOID)
The output is as follows:
```
create Timer1 success
start Timer1 success
Timer 1 created.
Timer 1 started.
tickCount=798
stop Timer1 success
Timer 1 stopped.
g_timerCount1=1, tick_last1=1208
start Timer2
Timer 2 started.
g_timerCount2=1 tick_last2=1313
g_timerCount2=2 tick_last2=1413
g_timerCount2=3 tick_last2=1513
......@@ -214,6 +214,6 @@ g_timerCount2=7 tick_last2=1913
g_timerCount2=8 tick_last2=2013
g_timerCount2=9 tick_last2=2113
g_timerCount2=10 tick_last2=2213
delete Timer2 success
Timer 2 deleted.
```
......@@ -121,7 +121,7 @@ VOID SendEntry(VOID)
ret = LOS_QueueWriteCopy(g_queue, abuf, len, 0);
if(ret != LOS_OK) {
printf("send message failure, error: %x\n", ret);
printf("Failed to send the message. Error: %x\n", ret);
}
}
......@@ -133,22 +133,22 @@ VOID RecvEntry(VOID)
ret = LOS_QueueReadCopy(g_queue, readBuf, &readLen, 0);
if(ret != LOS_OK) {
printf("recv message failure, error: %x\n", ret);
printf("Failed to receive the message. Error: %x\n", ret);
}
printf("recv message: %s\n", readBuf);
printf("Message received: %s\n", readBuf);
ret = LOS_QueueDelete(g_queue);
if(ret != LOS_OK) {
printf("delete the queue failure, error: %x\n", ret);
printf("Failed to delete the queue. Error: %x\n", ret);
}
printf("delete the queue success.\n");
printf("Queue deleted.\n");
}
UINT32 ExampleQueue(VOID)
{
printf("start queue example.\n");
printf("Start queue example.\n");
UINT32 ret = 0;
UINT32 task1, task2;
TSK_INIT_PARAM_S initParam = {0};
......@@ -161,7 +161,7 @@ UINT32 ExampleQueue(VOID)
LOS_TaskLock();
ret = LOS_TaskCreate(&task1, &initParam);
if(ret != LOS_OK) {
printf("create task1 failed, error: %x\n", ret);
printf("Failed to create task1. Error: %x\n", ret);
return ret;
}
......@@ -170,16 +170,16 @@ UINT32 ExampleQueue(VOID)
initParam.usTaskPrio = 10;
ret = LOS_TaskCreate(&task2, &initParam);
if(ret != LOS_OK) {
printf("create task2 failed, error: %x\n", ret);
printf("Failed to create task2. Error: %x\n", ret);
return ret;
}
ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
if(ret != LOS_OK) {
printf("create queue failure, error: %x\n", ret);
printf("Failed to create the queue. Error: %x\n", ret);
}
printf("create the queue success.\n");
printf("Queue created.\n");
LOS_TaskUnlock();
return ret;
}
......@@ -190,9 +190,9 @@ UINT32 ExampleQueue(VOID)
编译运行得到的结果为:
```
start queue example.
create the queue success.
recv message: test message.
delete the queue success.
Start queue example.
Queue created.
Message received: test message.
Queue deleted.
```
......@@ -208,30 +208,30 @@ VOID Example_DynMem(VOID)
/*初始化内存池*/
ret = LOS_MemInit(g_testPool, TEST_POOL_SIZE);
if (LOS_OK == ret) {
printf("Mem init success!\n");
printf("Memory pool initialized.\n");
} else {
printf("Mem init failed!\n");
printf("Memory pool initialization failed.\n");
return;
}
/*分配内存*/
mem = (UINT32 *)LOS_MemAlloc(g_testPool, 4);
if (NULL == mem) {
printf("Mem alloc failed!\n");
printf("Memory allocation failed.\n");
return;
}
printf("Mem alloc success!\n");
printf("Memory allocated.\n");
/*赋值*/
*mem = 828;
printf("*mem = %d\n", *mem);
printf("*Memory = %d\n", *mem);
/*释放内存*/
ret = LOS_MemFree(g_testPool, mem);
if (LOS_OK == ret) {
printf("Mem free success!\n");
printf("Memory released.\n");
} else {
printf("Mem free failed!\n");
printf("Memory release failed.\n");
}
return;
......@@ -243,9 +243,9 @@ VOID Example_DynMem(VOID)
输出结果如下:
```
Mem init success!
Mem alloc success!
*mem = 828
Mem free success!
Memory pool initialized.
Memory allocated.
*Memory = 828
Memory released.
```
......@@ -140,29 +140,29 @@ void Timer_example(void)
/*创建周期性软件定时器,每100Tick数执行回调函数2 */
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
printf("create Timer1 success\n");
printf("Timer 1 created.\n");
LOS_SwtmrStart(id1); //启动单次软件定时器
printf("start Timer1 success\n");
printf("Timer 1 started.\n");
LOS_TaskDelay(200); //延时200Tick数
LOS_SwtmrTimeGet(id1, &tickCount); // 获得单次软件定时器剩余Tick数
printf("tickCount=%d\n", tickCount);
LOS_SwtmrStop(id1); // 停止软件定时器
printf("stop Timer1 success\n");
printf("Timer 1 stopped.\n");
LOS_SwtmrStart(id1);
LOS_TaskDelay(1000);
LOS_SwtmrStart(id2); // 启动周期性软件定时器
printf("start Timer2\n");
printf("Timer 2 started.\n");
LOS_TaskDelay(1000);
LOS_SwtmrStop(id2);
ret = LOS_SwtmrDelete(id2); // 删除软件定时器
if (ret == LOS_OK) {
printf("delete Timer2 success\n");
printf("Timer 2 deleted.\n");
}
}
......@@ -182,7 +182,7 @@ UINT32 Example_TaskEntry(VOID)
task1.usTaskPrio = 5;
ret = LOS_TaskCreate(&g_testTaskId01, &task1);
if (ret != LOS_OK) {
printf("TimerTsk create failed.\n");
printf("Failed to create the timer task.\n");
return LOS_NOK;
}
......@@ -198,12 +198,12 @@ UINT32 Example_TaskEntry(VOID)
编译烧录运行,输出结果如下:
```
create Timer1 success
start Timer1 success
Timer 1 created.
Timer 1 started.
tickCount=798
stop Timer1 success
Timer 1 stopped.
g_timerCount1=1, tick_last1=1208
start Timer2
Timer 2 started.
g_timerCount2=1 tick_last2=1313
g_timerCount2=2 tick_last2=1413
g_timerCount2=3 tick_last2=1513
......@@ -214,6 +214,6 @@ g_timerCount2=7 tick_last2=1913
g_timerCount2=8 tick_last2=2013
g_timerCount2=9 tick_last2=2113
g_timerCount2=10 tick_last2=2213
delete Timer2 success
Timer 2 deleted.
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册