-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (31 loc) · 801 Bytes
/
main.go
File metadata and controls
38 lines (31 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"log"
"time"
"github.com/600888/go-dlt645/common"
"github.com/600888/go-dlt645/service/serversvc"
)
func main() {
common.InitLogger()
defer common.LogFile.Close()
log.Println("start server")
serverSvc, err := serversvc.NewTcpServer("127.0.0.1", 10521, 5*time.Second)
if err != nil {
log.Printf("创建TCP服务器失败: %v", err)
}
err = serverSvc.SetAddress([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
if err != nil {
log.Printf("设置通讯地址失败: %v", err)
return
}
// 设置电能数据
_, err = serverSvc.Set00(0x00000000, 123456.78)
if err != nil {
log.Printf("设置电能数据失败: %v", err)
return
}
// 启动服务器
if err := serverSvc.Server.Start(); err != nil {
log.Printf("启动TCP服务器失败: %v", err)
}
}