Forráskód Böngészése

【修改】函数命令更改为适当名称
【修改】多设备注册断言问题

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

liuxianliang 6 éve
szülő
commit
c22fd0936d
2 módosított fájl, 14 hozzáadás és 13 törlés
  1. 6 5
      samples/ppp_sample_air720.c
  2. 8 8
      src/ppp_device.c

+ 6 - 5
samples/ppp_sample_air720.c

@@ -35,7 +35,7 @@ static struct ppp_air720 air720;
  *
  */
 
-int air720_register(void)
+int ppp_air720_register(void)
 {
     int result = RT_EOK;
 
@@ -47,9 +47,9 @@ int air720_register(void)
 
     return result;
 }
-INIT_ENV_EXPORT(air720_register);
+INIT_ENV_EXPORT(ppp_air720_register);
 
-int air720_start(void)
+int ppp_air720_start(void)
 {
     rt_device_t device = RT_NULL;
 
@@ -68,8 +68,8 @@ int air720_start(void)
 
     return RT_EOK;
 }
-INIT_APP_EXPORT(air720_start);
-MSH_CMD_EXPORT(air720_start, a sample create air720 for dail to network);
+INIT_APP_EXPORT(ppp_air720_start);
+MSH_CMD_EXPORT(ppp_air720_start, a sample create air720 for dail to network);
 /*
  * close air720 ppp mode, hang up from network
  *
@@ -99,3 +99,4 @@ int ppp_air720_stop(void)
     return RT_EOK;
 }
 MSH_CMD_EXPORT(ppp_air720_stop, a sample stop air720 for dail to network);
+

+ 8 - 8
src/ppp_device.c

@@ -28,7 +28,7 @@
 #endif
 
 
-static struct ppp_device *_g_ppp_device = NULL;
+static struct ppp_device *_g_ppp_device = RT_NULL;
 
 /*
  * Receive callback function , release rx_notice when uart acquire data
@@ -393,8 +393,6 @@ static rt_err_t ppp_device_open(struct rt_device *device, rt_uint16_t oflag)
     RT_ASSERT(ppp_device != RT_NULL);
     static rt_device_t serial;
 
-    ppp_device->parent.ref_count++;
-
     ppp_device->ppp_link_status = 1;
     /* Creat a thread to creat ppp recieve function */
     result = ppp_recv_entry_creat(ppp_device);
@@ -582,13 +580,15 @@ int ppp_device_register(struct ppp_device *ppp_device, const char *dev_name, con
 
     rt_strncpy((char *)ppp_device->rely_name, rely_name, rt_strlen(rely_name));
 
+    /* now we supprot only one device */
+    if (_g_ppp_device != RT_NULL)
+    {
+        LOG_E("Only one device support.");
+        RT_ASSERT(_g_ppp_device == RT_NULL);
+    }
+
     /* attention: you can't use ppp_device as a server in you network, unless
      sim of the modem module used supprots getting public IP address. */
-     if(_g_ppp_device != RT_NULL)
-     {
-         RT_ASSERT("Only one device support.");
-     }
-
     /* register ppp device into rt_device frame */
     result = rt_device_register(&ppp_device->parent, dev_name, RT_Device_Class_NetIf);
     if( result == RT_EOK)