Просмотр исходного кода

【修改】对 RT-Thread 系统版本依赖描述
【修改】sample文件中register函数重命名
【修改】接收线程的接收逻辑更改

Signed-off-by: liuxianliang <liuxianliang@rt-thread.com>

liuxianliang 6 лет назад
Родитель
Сommit
0813134712
3 измененных файлов с 46 добавлено и 46 удалено
  1. 1 1
      README.md
  2. 2 2
      samples/ppp_sample_air720.c
  3. 43 43
      src/ppp_device.c

+ 1 - 1
README.md

@@ -22,7 +22,7 @@ ppp_device 软件包遵循 Apache-2.0 许可,详见 LICENSE 文件。
 
 ### 1.3 依赖 ###
 
-- RT_Thread 4.0.0+
+- RT_Thread 3.1.x+
 - lwIP 组件( ppp 功能)
 
 ## 2. 获取方式 ##

+ 2 - 2
samples/ppp_sample_air720.c

@@ -35,7 +35,7 @@ static struct ppp_air720 air720;
  *
  */
 
-int ppp_air720_register(void)
+int air720_ppp_register(void)
 {
     int result = RT_EOK;
 
@@ -47,7 +47,7 @@ int ppp_air720_register(void)
 
     return result;
 }
-INIT_ENV_EXPORT(ppp_air720_register);
+INIT_ENV_EXPORT(air720_ppp_register);
 
 int ppp_air720_start(void)
 {

+ 43 - 43
src/ppp_device.c

@@ -222,55 +222,55 @@ static int ppp_recv_entry(struct ppp_device *device)
         rt_sem_take(device->rx_notice, RT_WAITING_FOREVER);
 
         /* uart devcie , recieve data from uart and store data in the recv_buff */
-        rt_device_read(recv_dev, 0, &ch, 1);
-
-        /* begin to recieve data from uart */
-        if (thrans_flag == 1)
+        while (rt_device_read(recv_dev, 0, &ch, 1))
         {
-            /* if recieve 0x7e twice */
-            if (ch == 0x7e && old_ch == 0x7e)
-            {
-                /* choice the least 0x7e as frame head */
-                device->recv_line_buf[0] = ch;
-                device->recv_line_len = 1;
-
-                old_ch = ch;
-            }
-            else if(ch == 0x7e && old_ch == 0x00)
+            /* begin to recieve data from uart */
+            if (thrans_flag == 1)
             {
-                thrans_flag = 2;
-                device->recv_line_buf[device->recv_line_len] = ch;
+                /* if recieve 0x7e twice */
+                if (ch == 0x7e && old_ch == 0x7e)
+                {
+                    /* choice the least 0x7e as frame head */
+                    device->recv_line_buf[0] = ch;
+                    device->recv_line_len = 1;
+
+                    old_ch = ch;
+                }
+                else if (ch == 0x7e && old_ch == 0x00)
+                {
+                    thrans_flag = 2;
+                    device->recv_line_buf[device->recv_line_len] = ch;
+                }
+                else
+                {
+                    old_ch = 0x00;
+                    device->recv_line_buf[device->recv_line_len] = ch;
+                    device->recv_line_len++;
+                }
+
+                /* when a frame is end, put data into tcpip */
+                if (thrans_flag == 2)
+                {
+                    rt_enter_critical();
+                    pppos_input_tcpip(device->pcb, (u8_t *)device->recv_line_buf, device->recv_line_len + 1);
+                    rt_exit_critical();
+
+                    thrans_flag = 0;
+                    device->recv_line_len = 0;
+                }
             }
             else
             {
-                old_ch = 0x00;
-                device->recv_line_buf[device->recv_line_len] = ch;
-                device->recv_line_len++;
-            }
-
-            /* when a frame is end, put data into tcpip */
-            if (thrans_flag == 2)
-            {
-                rt_enter_critical();
-                pppos_input_tcpip(device->pcb, (u8_t *)device->recv_line_buf, device->recv_line_len + 1);
-                rt_exit_critical();
-
-                thrans_flag = 0;
-                device->recv_line_len = 0;
+                /* if recieve 0x7e, begin to recieve data */
+                if (ch == 0x7e)
+                {
+                    thrans_flag = 1;
+                    old_ch = ch;
+                    device->recv_line_buf[0] = ch;
+                    device->recv_line_len = 1;
+                }
             }
         }
-        else
-        {
-            /* if recieve 0x7e, begin to recieve data */
-            if (ch == 0x7e)
-            {
-                thrans_flag = 1;
-                old_ch = ch;
-                device->recv_line_buf[0] = ch;
-                device->recv_line_len = 1;
-            }
-        }
-
     }
 
 __exit:
@@ -478,7 +478,7 @@ static rt_err_t ppp_device_open(struct rt_device *device, rt_uint16_t oflag)
         result = -RT_ERROR;
         goto __exit;
     }
-    LOG_D("pppapi_connect execute successful, ppp has connected.");
+    LOG_D("pppapi_connect execute successful, waitting connect.");
 
 __exit: