提交 f0014aae 编写于 作者: O openharmony_ci 提交者: Gitee

!642 !640 Done! [Auto] This is an English translation task.[626]

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