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

文件写入bug,modbus TCP 固定IPbug

liyi 1 éve%!(EXTRA string=óta)
szülő
commit
4c703a216b
4 módosított fájl, 19 hozzáadás és 8 törlés
  1. 1 1
      ip/src/cascade.c
  2. 2 2
      ip/src/common.c
  3. 13 3
      ip/src/file.c
  4. 3 2
      ip/src/sys.c

+ 1 - 1
ip/src/cascade.c

@@ -2025,7 +2025,7 @@ int cascade_init(void)
     {
         addr = dm->_globalDevInfo._gmodbus_info.product_modbus_addr;
     }
-    dm->md_tcp = tcp_modbus_init(net.ip_address,CASCADE_SLAVE_PORT,addr,dm->_globalDevInfo.product_pwr_type);
+    dm->md_tcp = tcp_modbus_init("0.0.0.0",CASCADE_SLAVE_PORT,addr,dm->_globalDevInfo.product_pwr_type);
     if(dm->md_tcp){
         thread_start(THREAD_ID_TCP, tcp_modbus_thread, cas, 4*MB, 0);
     }else {

+ 2 - 2
ip/src/common.c

@@ -380,9 +380,9 @@ int set_utctime(time_t t)
     sleep(1);
     //system("hwclock -w -f /dev/rtc0");
     //system("hwclock -w");
-    system("hwclock --show");
+    //system("hwclock --show");
     
-    system("hwclock -s");
+    //system("hwclock -s");
     
     return 0;
     

+ 13 - 3
ip/src/file.c

@@ -2,6 +2,7 @@
 #include <sys/stat.h>
 #include "file.h"
 #include "unistd.h"
+#include "fcntl.h"
 
 
 #if 0
@@ -30,9 +31,17 @@ int file_length(char* path)
 
 int file_save(char *path, void *buf, int len)
 {
-    int r;
+    int r = 0;
     FILE *fp;
-    
+
+    int fd = open(path,O_RDWR|O_TRUNC,0777);
+
+    write(fd,buf,len);
+
+    close(fd);
+    sync();
+
+ #if 0   
     fp = fopen(path, "w");
     if(!fp) {
         LOGE("file_save, fopen %s failed\n", path);
@@ -48,7 +57,8 @@ int file_save(char *path, void *buf, int len)
     }
     fflush(fp);
     fclose(fp);
-
+    sync();
+#endif
     return r;
 }
 

+ 3 - 2
ip/src/sys.c

@@ -840,12 +840,13 @@ int sys_set_net(NetworkInfo_t *para, int ipVersion)
                 memset(buff,0,sizeof(buff));
                 sprintf(buff,"%s %s","route add default gw ",para->gateway);
                 system(buff);
-                exit(0);
+                system("reboot");
             }else
             {
                 system("reboot");
-            }
+            
             //system("ifconfig eth0 down; ifconfig eth0 up");
+            }
             
         }
     }