diff --git a/main.go b/main.go index c912c26..e972dd5 100644 --- a/main.go +++ b/main.go @@ -13,9 +13,9 @@ func main() { go gw_router() go serial_run() c := cron.New() - // send_data(1001) + send_data(1001) c.AddFunc("0, *, *, *, *, *", func() { - // send_data(1001) + send_data(1001) }) // devices := []Device{} c.AddFunc("*/10, *, *, *, *, *", func(){ diff --git a/tcpserver.go b/tcpserver.go index c30284f..f45b0c2 100644 --- a/tcpserver.go +++ b/tcpserver.go @@ -33,12 +33,14 @@ func handleConn(conn net.Conn) { go yunhorn_ys_l_v1(readStr) case stop := <-stopChan: if stop { + log.Println("stop channel") break } case <-time.After(5000 * time.Millisecond): n,err := conn.Write(heartbeat) if err != nil{ log.Println("write msg error!",err) + stopChan <- true }else{ log.Println("write msg success!",n) } diff --git a/worker.go b/worker.go index 4f96f2f..512683e 100644 --- a/worker.go +++ b/worker.go @@ -34,6 +34,7 @@ func yunhorn_ys_l_v1(data_buf []byte){ // log.Println(binary.BigEndian.Uint16(append([]byte{0x00}, k)) // } + log.Println("ys_l_v1_data:",data_buf) data_int := Bytes2Bits(data_buf[3:4]) log.Println("data_int:",data_int[0]) @@ -53,7 +54,7 @@ func yunhorn_ys_l_v1(data_buf []byte){ if conf.DEBUG { log.Println(device) } - // send_data(1005, device) + send_data(1005, device) }