Procházet zdrojové kódy

Merge pull request #3 from xiangxistu/master

【修改】对 RT-Thread 系统版本依赖描述
朱天龙 (Armink) před 6 roky
rodič
revize
4492b8b3d2
2 změnil soubory, kde provedl 45 přidání a 45 odebrání
  1. 2 2
      samples/ppp_sample_air720.c
  2. 43 43
      src/ppp_device.c

+ 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: