guohui 1 рік тому
батько
коміт
4172888232

+ 1 - 2
f407/applications/board.c

@@ -12,7 +12,6 @@
 #include <board.h>
 #include <drv_common.h>
 
-
 void rt_hw_board_init()
 {
     struct rt_memheap heap;
@@ -21,7 +20,7 @@ void rt_hw_board_init()
     /* Heap initialization */
 #if defined(RT_USING_HEAP)
     rt_system_heap_init((void *) HEAP_BEGIN1, (void *) HEAP_END1);
-    rt_memheap_init(&heap, "sram2", (void *)RAM2_START, RAM2_SIZE);
+    rt_memheap_init(&heap, "sram2", (void *)HEAP_BEGIN2, HEAP_END2-(uint32_t)HEAP_BEGIN2);
 #endif
 
     hw_board_init(BSP_CLOCK_SOURCE, BSP_CLOCK_SOURCE_FREQ_MHZ, BSP_CLOCK_SYSTEM_FREQ_MHZ);

+ 1 - 1
f407/applications/datadef.h

@@ -273,6 +273,7 @@ typedef struct {
 }alarm_data_t;
 
 typedef struct {
+    char                name[32];
     uint8_t             type;
     uint8_t             addr;
     uint8_t             ch;                      //该通道在全部板上的所排序号,程序始于0,用户始于1
@@ -284,7 +285,6 @@ typedef struct {
     uint32_t            stop_delay;
 }info_t;
 typedef struct {
-    char                name[32];
     info_t              info;
     power_t             power[3];                 //电力信息
     thr_t               thr;                      //阈值

+ 0 - 3
f407/applications/main.c

@@ -114,11 +114,8 @@ static int user_init(void)
     //ui_init();
     sd_mount();
     
-LOGD("___ user 111\n");
     power_init();
-LOGD("___ user 222\n");
     web_init();
-LOGD("___ user 333\n");
     
     return 0;
 }

+ 1 - 1
f407/applications/packages/mongoose-v6.7/7.16/mongoose.h

@@ -810,7 +810,7 @@ struct timeval {
 #endif
 
 #ifndef MG_MAX_RECV_SIZE
-#define MG_MAX_RECV_SIZE (8UL * 1024UL)  // Maximum recv IO buffer size
+#define MG_MAX_RECV_SIZE (20UL * 1024UL)  // Maximum recv IO buffer size
 #endif
 
 #ifndef MG_DATA_SIZE

+ 2 - 2
f407/applications/packages/mongoose-v6.7/mongoose.h

@@ -291,7 +291,7 @@ int mkdir(const char *, mode_t);
 #include <time.h>
 
 #ifndef MG_IO_SIZE
-#define MG_IO_SIZE 1460
+#define MG_IO_SIZE  (1460)
 #endif
 
 #endif // MG_ARCH == MG_ARCH_RTTHREAD
@@ -810,7 +810,7 @@ struct timeval {
 #endif
 
 #ifndef MG_MAX_RECV_SIZE
-#define MG_MAX_RECV_SIZE (8UL * 1024UL)  // Maximum recv IO buffer size
+#define MG_MAX_RECV_SIZE (10UL * 1024UL)  // Maximum recv IO buffer size
 #endif
 
 #ifndef MG_DATA_SIZE

+ 0 - 3
f407/applications/power.c

@@ -641,11 +641,8 @@ static void power_thread(void *arg)
     power_handle_t *h=(power_handle_t*)th->attr->arg;;
     
     while(th->quit==0) {
-        LOGD("___ board_query 111\n");
         board_query(h);
-        LOGD("___ board_query 222\n");
         sleep(1);
-        LOGD("___ board_query 333\n");
     }
 }
 

+ 11 - 1
f407/applications/rtconfig.h

@@ -154,6 +154,13 @@
 #define RT_USING_LWIP_VER_NUM 0x20102
 #define RT_LWIP_MEM_ALIGNMENT 4
 
+//lwip debug setting
+#define RT_LWIP_DEBUG
+//#define RT_LWIP_PBUF_DEBUG
+#define RT_LWIP_TCPIP_DEBUG
+#define RT_LWIP_TCP_OUTPUT_DEBUG
+
+
 #define RT_LWIP_TCP
 #define RT_LWIP_UDP
 #define RT_LWIP_IGMP
@@ -172,7 +179,10 @@
 #define RT_LWIP_TCP
 #define RT_LWIP_RAW
 #define RT_MEMP_NUM_NETCONN 8
-#define RT_LWIP_PBUF_NUM 16
+//#define PBUF_POOL_SIZE   4
+//#define RT_LWIP_PBUF_NUM 16
+//#define RT_LWIP_PBUF_POOL_BUFSIZE  1024
+
 #define RT_LWIP_RAW_PCB_NUM 4
 #define RT_LWIP_UDP_PCB_NUM 4
 #define RT_LWIP_TCP_PCB_NUM 4

+ 60 - 276
f407/applications/web.c

@@ -44,9 +44,27 @@ typedef struct {
 }web_handle_t;
 static web_handle_t webHandle={0};
 
-
-
-static int ws_send(web_handle_t *h, struct mg_connection *c, uint8_t type, void *data, int len, int isbin)
+static int is_ws(struct mg_connection *c)
+{
+    int r=0;
+#ifdef USE_MG716
+    r = c->is_websocket;
+#else
+    r = (c->flags & MG_F_IS_WEBSOCKET)?1:0;
+#endif
+}
+static int ws_send(struct mg_connection *c, void *data, int len, int isbin)
+{
+    LOGD("____ws_send, len: %d\n", len);
+#ifdef USE_MG716
+    mg_ws_send(c, data, len, isbin?WEBSOCKET_OP_BINARY:WEBSOCKET_OP_TEXT);
+#else
+    mg_send_websocket_frame(c, isbin?WEBSOCKET_OP_BINARY:WEBSOCKET_OP_TEXT, data, len);
+#endif
+    
+    return 0;
+}
+static int ws_send_pkt(web_handle_t *h, struct mg_connection *c, uint8_t type, void *data, int len, int isbin)
 {
     pkt_hdr_t *hdr=NULL;
     
@@ -61,48 +79,62 @@ static int ws_send(web_handle_t *h, struct mg_connection *c, uint8_t type, void
     hdr->nack  = 0;
     hdr->dlen  = len;
     memcpy(hdr->data, data, len);
-#ifdef USE_MG716
-    mg_ws_send(c, hdr, len+sizeof(pkt_hdr_t), isbin?WEBSOCKET_OP_BINARY:WEBSOCKET_OP_TEXT);
-#else
-    mg_send_websocket_frame(c, isbin?WEBSOCKET_OP_BINARY:WEBSOCKET_OP_TEXT, hdr, len+sizeof(pkt_hdr_t));
-#endif
+
+    ws_send(c, hdr, len+sizeof(pkt_hdr_t), isbin);
     
     return 0;
 }
+
 static void send_powerc(web_handle_t *h, struct mg_connection *c)
 {
-    int i,r;
+    int i,xlen,offset;
+    pkt_hdr_t *hdr=NULL;
     power_data_t pd=power_data_get();
     
+    //pd.chs = 2;
+    if(pd.chs==0) {
+        return;
+    }
+    
+    xlen = pd.chs*sizeof(power_ch_t)+sizeof(pkt_hdr_t);
+    if(!h->buf || h->buflen<xlen) {
+        if(h->buf) free(h->buf);
+        h->buf = malloc(xlen);
+        if(h->buf) {
+            h->buflen = xlen;
+        }
+    }
+
+    if(!h->buf) {
+        return;
+    }
+    hdr = (pkt_hdr_t*)h->buf;
+
+    hdr->magic = PKT_MAGIC;
+    hdr->type  = PKT_TYPE_POWER_CH;
+    hdr->nack  = 0;
+    hdr->dlen  = xlen-sizeof(pkt_hdr_t);
     for(i=0; i<pd.chs; i++) {
-        ws_send(h, c, PKT_TYPE_POWER_CH, &pd.pch[i], sizeof(power_ch_t), 1);
+        offset = i*sizeof(power_ch_t);
+        memcpy(hdr->data+offset, &pd.pch[i], sizeof(power_ch_t));
     }
+    ws_send(c, h->buf, xlen, 1);
 }
 static void send_powert(web_handle_t *h, struct mg_connection *c)
 {
     int i,r;
     power_data_t pd=power_data_get();
     
-    if(r==0) {
-        ws_send(h, c, PKT_TYPE_POWER_TOTAL, &pd.ttl, sizeof(power_total_t), 1);
-    }
+    ws_send_pkt(h, c, PKT_TYPE_POWER_TOTAL, &pd.ttl, sizeof(power_total_t), 1);
 }
 
 
-static int is_websocket(struct mg_connection *c)
-{
-    int r=0;
-#ifdef USE_MG716
-    r = c->is_websocket;
-#else
-    r = (c->flags & MG_F_IS_WEBSOCKET)?1:0;
-#endif
-}
+
 static int ws_handle(web_handle_t *h, pkt_hdr_t *hdr, struct mg_connection *c)
 {
     int r=0;
     
-    if (!is_websocket(c)) {
+    if (!is_ws(c)) {
         return -1;
     }
     
@@ -285,7 +317,7 @@ static void timer_fn(void *arg)
 #else
         for (c = mg_next(&h->mgr, NULL); c != NULL; c = mg_next(&h->mgr, c)) {
 #endif
-            ws_send(h, c, n->tp, n->buf, n->dlen, 1);
+            ws_send_pkt(h, c, n->tp, n->buf, n->dlen, 1);
         }
         list_back_node(h->list, ln);
     }
@@ -295,9 +327,8 @@ static void web_thread(void *arg)
     struct mg_connection *nc;
     const char *http_addr="http://[::]:80";
     const char *https_addr="https://[::]:443";
-    //thread_handle_t *th=(thread_handle_t*)arg;
-    //web_handle_t *h=(web_handle_t*)th->attr->arg;
-    web_handle_t *h=&webHandle;
+    thread_handle_t *th=(thread_handle_t*)arg;
+    web_handle_t *h=(web_handle_t*)th->attr->arg;
 
 #ifdef USE_MG716
     mg_log_set(MG_LL_DEBUG);
@@ -306,7 +337,7 @@ static void web_thread(void *arg)
     //sys_get_path(mh->rootDir, WEB_ROOT);
     strcpy(h->rootDir, "/web");
 
-    mg_timer_add(&h->mgr, TIMER_INTERVAL, MG_TIMER_REPEAT, timer_fn, h);
+    //mg_timer_add(&h->mgr, TIMER_INTERVAL, MG_TIMER_REPEAT, timer_fn, h);
     if (mg_http_listen(&h->mgr, http_addr, http_fn, NULL) == NULL) {
         MG_ERROR(("cannot listen on %s\n", http_addr));
     }
@@ -329,8 +360,7 @@ static void web_thread(void *arg)
     h->opts.enable_directory_listing = "yes";
 #endif
     
-    //while(th->quit==0) {
-    while(1) {
+    while(th->quit==0) {
         mg_mgr_poll(&h->mgr, 300);
     }
     mg_mgr_free(&h->mgr);
@@ -348,7 +378,6 @@ int web_init(void)
     h->buflen = sizeof(pkt_hdr_t)+sizeof(power_ch_t)+32;
     h->buf = (char*)malloc(h->buflen);
     
-    //web_thread(0);
     thread_start(THREAD_ID_WEB, web_thread, h);
     return 0;
 }
@@ -363,251 +392,6 @@ int web_post(int type, void *data, int len)
     return list_append(h->list, type, data, len);
 }
 
-#if 1
-void WWDG_IRQHandler() {
-    LOGD("___0\n");
-}    
-void PVD_IRQHandler() {
-    LOGD("___1\n");
-}    
-void TAMP_STAMP_IRQHandler(){
-    LOGD("___2\n");
-}    
-void RTC_WKUP_IRQHandler(){
-    LOGD("___3\n");
-}    
-void FLASH_IRQHandler(){
-    LOGD("___4\n");
-}    
-void RCC_IRQHandler(){
-    LOGD("___5\n");
-}    
-//void EXTI0_IRQHandler(){
-//    LOGD("___6\n");
-//}    
-//void EXTI1_IRQHandler(){
-//    LOGD("___7\n");
-//}    
-//void EXTI2_IRQHandler(){
-//    LOGD("___8\n");
-//}    
-//void EXTI3_IRQHandler(){
-//    LOGD("___9\n");
-//}    
-//void EXTI4_IRQHandler(){
-//    LOGD("___a\n");
-//}    
-void DMA1_Stream0_IRQHandler(){
-    LOGD("___b\n");
-}    
-void DMA1_Stream1_IRQHandler(){
-    LOGD("___c\n");
-}    
-void DMA1_Stream2_IRQHandler(){
-    LOGD("___d\n");
-}    
-void DMA1_Stream3_IRQHandler(){
-    LOGD("___e\n");
-}    
-void DMA1_Stream4_IRQHandler(){
-    LOGD("___f\n");
-}    
-void DMA1_Stream5_IRQHandler(){
-    LOGD("___g\n");
-}    
-void DMA1_Stream6_IRQHandler(){
-    LOGD("___h\n");
-}    
-void ADC_IRQHandler(){
-    LOGD("___i\n");
-}    
-void CAN1_TX_IRQHandler(){
-    LOGD("___j\n");
-}    
-void CAN1_RX0_IRQHandler(){
-    LOGD("___k\n");
-}    
-void CAN1_RX1_IRQHandler(){
-    LOGD("___l\n");
-}    
-void CAN1_SCE_IRQHandler(){
-    LOGD("___m\n");
-}    
-//void EXTI9_5_IRQHandler(){
-//    LOGD("___n\n");
-//}    
-void TIM1_BRK_TIM9_IRQHandler(){
-    LOGD("___o\n");
-}    
-void TIM1_UP_TIM10_IRQHandler(){
-    LOGD("___p\n");
-}    
-void TIM1_TRG_COM_TIM11_IRQHandler(){
-    LOGD("___q\n");
-}    
-void TIM1_CC_IRQHandler(){
-    LOGD("___r\n");
-}    
-void TIM2_IRQHandler(){
-    LOGD("___s\n");
-}    
-void TIM3_IRQHandler(){
-    LOGD("___t\n");
-}    
-void TIM4_IRQHandler(){
-    LOGD("___u\n");
-}    
-void I2C1_EV_IRQHandler(){
-    LOGD("___v\n");
-}    
-void I2C1_ER_IRQHandler(){
-    LOGD("___w\n");
-}    
-void I2C2_EV_IRQHandler(){
-    LOGD("___x\n");
-}    
-void I2C2_ER_IRQHandler(){
-    LOGD("___y\n");
-}    
-void SPI1_IRQHandler(){
-    LOGD("___z\n");
-}    
-void SPI2_IRQHandler(){
-    LOGD("___a1\n");
-}    
-//void USART1_IRQHandler(){
-//    LOGD("___a2\n");
-//}    
-//void USART2_IRQHandler(){
-//    LOGD("___a3\n");
-//}    
-//void USART3_IRQHandler(){
-//    LOGD("___a4\n");
-//}    
-//void EXTI15_10_IRQHandler(){
-//    LOGD("___a5\n");
-//}    
-void RTC_Alarm_IRQHandler(){
-    LOGD("___a6\n");
-}    
-void OTG_FS_WKUP_IRQHandler(){
-    LOGD("___a7\n");
-}    
-void TIM8_BRK_TIM12_IRQHandler(){
-    LOGD("___a8\n");
-}    
-void TIM8_UP_TIM13_IRQHandler(){
-    LOGD("___a9\n");
-}    
-void TIM8_TRG_COM_TIM14_IRQHandler(){
-    LOGD("___aa\n");
-}    
-void TIM8_CC_IRQHandler(){
-    LOGD("___ab\n");
-}    
-void DMA1_Stream7_IRQHandler(){
-    LOGD("___ac\n");
-}    
-void FMC_IRQHandler(){
-    LOGD("___ad\n");
-}    
-//void SDIO_IRQHandler(){
-//    LOGD("___ae\n");
-//}    
-void TIM5_IRQHandler(){
-    LOGD("___af\n");
-}    
-void SPI3_IRQHandler(){
-    LOGD("___ag\n");
-}    
-void UART4_IRQHandler(){
-    LOGD("___ah\n");
-}    
-void UART5_IRQHandler(){
-    LOGD("___b1\n");
-}    
-void TIM6_DAC_IRQHandler(){
-    LOGD("___b2\n");
-}    
-void TIM7_IRQHandler(){
-    LOGD("___b3\n");
-}    
-void DMA2_Stream0_IRQHandler(){
-    LOGD("___b4\n");
-}    
-void DMA2_Stream1_IRQHandler(){
-    LOGD("___b5\n");
-}    
-void DMA2_Stream2_IRQHandler(){
-    LOGD("___b6\n");
-}    
-void DMA2_Stream3_IRQHandler(){
-    LOGD("___b7\n");
-}    
-void DMA2_Stream4_IRQHandler(){
-    LOGD("___b8\n");
-}    
-//void ETH_IRQHandler(){
-//    LOGD("___b9\n");
-//}    
-void ETH_WKUP_IRQHandler(){
-    LOGD("___c1\n");
-}    
-void CAN2_TX_IRQHandler(){
-    LOGD("___c2\n");
-}    
-void CAN2_RX0_IRQHandler(){
-    LOGD("___c3\n");
-}    
-void CAN2_RX1_IRQHandler(){
-    LOGD("___c4\n");
-}    
-void CAN2_SCE_IRQHandler(){
-    LOGD("___c5\n");
-}    
-void OTG_FS_IRQHandler(){
-    LOGD("___c6\n");
-}    
-void DMA2_Stream5_IRQHandler(){
-    LOGD("___c7\n");
-}    
-void DMA2_Stream6_IRQHandler(){
-    LOGD("___c8\n");
-}    
-void DMA2_Stream7_IRQHandler(){
-    LOGD("___c9\n");
-}    
-//void USART6_IRQHandler(){
-//    LOGD("___d1\n");
-//}    
-void I2C3_EV_IRQHandler(){
-    LOGD("___d2\n");
-}    
-void I2C3_ER_IRQHandler(){
-    LOGD("___d3\n");
-}    
-void OTG_HS_EP1_OUT_IRQHandler(){
-    LOGD("___d4\n");
-}    
-void OTG_HS_EP1_IN_IRQHandler(){
-    LOGD("___d5\n");
-}    
-void OTG_HS_WKUP_IRQHandler(){
-    LOGD("___d6\n");
-}    
-void OTG_HS_IRQHandler(){
-    LOGD("___d7\n");
-}    
-void DCMI_IRQHandler(){
-    LOGD("___d8\n");
-}    
-void HASH_RNG_IRQHandler(){
-    LOGD("___d9\n");
-}    
-void FPU_IRQHandler(){
-    LOGD("___e1\n");
-}    
-#endif
 
 
 

+ 61 - 6
f407/project/app/app.uvoptx

@@ -120,6 +120,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
+          <Name>d</Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
@@ -147,32 +148,86 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024 -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint/>
+      <Breakpoint>
+        <Bp>
+          <Number>0</Number>
+          <Type>0</Type>
+          <LineNumber>286</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134462078</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>&lt;1&gt;..\..\rt-thread\components\net\lwip\lwip-2.1.2\src\core\pbuf.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\app\../../rt-thread/components/net/lwip/lwip-2.1.2/src/core/pbuf.c\286</Expression>
+        </Bp>
+        <Bp>
+          <Number>1</Number>
+          <Type>0</Type>
+          <LineNumber>280</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134462064</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>&lt;1&gt;..\..\rt-thread\components\net\lwip\lwip-2.1.2\src\core\pbuf.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\app\../../rt-thread/components/net/lwip/lwip-2.1.2/src/core/pbuf.c\280</Expression>
+        </Bp>
+        <Bp>
+          <Number>2</Number>
+          <Type>0</Type>
+          <LineNumber>284</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134462068</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>&lt;1&gt;..\..\rt-thread\components\net\lwip\lwip-2.1.2\src\core\pbuf.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\app\../../rt-thread/components/net/lwip/lwip-2.1.2/src/core/pbuf.c\284</Expression>
+        </Bp>
+      </Breakpoint>
       <WatchWindow1>
         <Ww>
           <count>0</count>
           <WinNumber>1</WinNumber>
-          <ItemText>h</ItemText>
+          <ItemText>io-&gt;len,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>1</count>
           <WinNumber>1</WinNumber>
-          <ItemText>h</ItemText>
+          <ItemText>xlen,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>2</count>
           <WinNumber>1</WinNumber>
-          <ItemText>hm-&gt;uri</ItemText>
+          <ItemText>tttt,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>3</count>
           <WinNumber>1</WinNumber>
-          <ItemText>m-&gt;ifaces[i]</ItemText>
+          <ItemText>n,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>4</count>
           <WinNumber>1</WinNumber>
-          <ItemText>mg_num_ifaces</ItemText>
+          <ItemText>len,0x0A</ItemText>
+        </Ww>
+        <Ww>
+          <count>5</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>alloc_len,0x0A</ItemText>
         </Ww>
       </WatchWindow1>
       <MemoryWindow1>

+ 30 - 11
f407/tools/web/data.js

@@ -40,11 +40,13 @@ function array_to_string(data){
     return s;
 }
 
-function string_to_array(data,attr){
+function string_to_array(data,len){
+    var buffer = new ArrayBuffer(len);
     for(var i=0;i<data.length;i++){
-        attr[i] = data.charCodeAt(i);
+        buffer[i] = data.charCodeAt(i);
     }
-    return attr;
+    buffer[len-1] = 0;
+    return buffer;
 }
 function array_cat(a1,a2){
     var tlen=a1.byteLength+a2.byteLength;
@@ -127,6 +129,9 @@ function bin_to_hdr(bin) {
 function bin_to_info(bin) {
     var tmp, length=0;
 
+    this.name = array_to_string(bin.slice(0,32));
+    length += 32;
+
     tmp = new DataView(bin, length);
     this.type = tmp.getUint8(0,true);
     length += 1;
@@ -188,10 +193,6 @@ function bin_to_power(bin) {
     this.consump = tmp.getFloat32(0,true);
     length += 4;
     
-    tmp = new DataView(bin, length);
-    this.factor = tmp.getFloat32(0,true);
-    length += 4;
-    
     tmp = new DataView(bin, length);
     this.active = tmp.getFloat32(0,true);
     length += 4;
@@ -307,11 +308,11 @@ function bin_to_powerc(bin) {
     
     tmp = new DataView(bin, length);
     this.time = tmp.getUint32(0,true);
-    length += this.time.len;
+    length += 4;
     
     tmp = new DataView(bin, length);
     this.pbrd = tmp.getUint32(0,true);
-    length += this.pbrd.len;
+    length += 4;
 
     this.len = length;
 }
@@ -414,6 +415,8 @@ function info_to_bin(js) {
     var tmp, length=0;
     var buffer = new ArrayBuffer(js.len);
 
+    var name = string_to_array(js.name);
+
     tmp = new DataView(buffer, length);
     tmp.setUint8(0,js.type,true);
     length += 1;
@@ -446,7 +449,7 @@ function info_to_bin(js) {
     tmp.setUint32(0,js.stop_delay,true);
     length += 4;
 
-    return buffer;
+    return array_cat(name,buffer);
 }
 function power_to_bin(js) {
     var tmp, length=0;
@@ -736,7 +739,15 @@ XXX.powerc=function() {
     }
 
     this.b2j = function (bin) {
-        return new bin_to_powerc(bin);
+        var tmp=[],length=0;
+        for(var i=0;; i++) {
+            tmp[i] =  new bin_to_powerc(bin.slice(length));
+            length += tmp[i].len;
+            if(length >= bin.byteLength) {
+                break;
+            }
+        }
+        return tmp;
     }
 };
 XXX.powert=function() {
@@ -841,9 +852,17 @@ function WS(url,fn) {
         }
     }
 
+    function loop_send() {
+        console.log("PKT_TYPE_POWER_CH request");
+        _send(mk_hdr(PKT_TYPE.PKT_TYPE_POWER_CH));
+        setTimeout(loop_send, 2000);
+    }
+
+
     function _onopen(evt) {
         his.closeCount = 0;
         console.log("___ ws.onopen");
+        setTimeout(loop_send, 2000);
     }
 
     function _onclose(evt) {

+ 1 - 1
f407/tools/web/index.html

@@ -26,7 +26,7 @@
 
 
     var ws = new WS("ws://192.168.234.132/ws",on_ws_msg);
-
+