Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
golangphone10
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangjie
golangphone10
Commits
346879e5
Commit
346879e5
authored
Aug 21, 2021
by
zhangjiec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
统计socket连接数量的变量改为原子操作
parent
ab1316b4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
23 deletions
+77
-23
config.ini
config.ini
+3
-4
dc_phone10_http_server.go
devproduct/dcphone10/dc_phone10_http_server.go
+19
-2
dc_phone10_para_json.go
devproduct/dcphone10/dc_phone10_para_json.go
+10
-0
dc_phone10_tcp.go
devproduct/dcphone10/dc_phone10_tcp.go
+34
-11
go.mod
go.mod
+1
-0
go.sum
go.sum
+2
-0
jeffutil_test.go
jeffutil/jeffutil_test.go
+7
-4
panic.log
log/panic.log
+0
-0
jeff_hex_server.go
tcplongserver/jeff_hex_server.go
+1
-2
No files found.
config.ini
View file @
346879e5
...
@@ -4,9 +4,8 @@ ServerMode = release
...
@@ -4,9 +4,8 @@ ServerMode = release
ServerPort
=
:50000
ServerPort
=
:50000
[http_client]
[http_client]
#BaseUrl = http://handandev.swaylink.cn/phone/2/server/
BaseUrl
=
http://handandev.swaylink.cn/phone/2/server/
#BaseUrl = http://dev.lezhixy.com/phone/2/server/
#BaseUrl = http://dev.lezhixy.com:5000/phone/2/server/
BaseUrl
=
http://127.0.0.1:1234/phone/2/server/
TimeOut
=
5
TimeOut
=
5
[tcp_long_server]
[tcp_long_server]
...
@@ -44,5 +43,5 @@ WarnWithMaxAge = 90
...
@@ -44,5 +43,5 @@ WarnWithMaxAge = 90
#Error级别日志最多保存多少份
#Error级别日志最多保存多少份
ErrorMaxFileNum
=
10
ErrorMaxFileNum
=
10
#Error日志最长保留天数
#Error日志最长保留天数
s
ErrorWithMaxAge
=
180
ErrorWithMaxAge
=
180
devproduct/dcphone10/dc_phone10_http_server.go
View file @
346879e5
...
@@ -289,11 +289,11 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
...
@@ -289,11 +289,11 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
sTcpData
.
Data
[
0
]
=
data
.
Value
sTcpData
.
Data
[
0
]
=
data
.
Value
sTcpData
.
Length
=
1
sTcpData
.
Length
=
1
sDevId
=
data
.
DevID
sDevId
=
data
.
DevID
case
"key_password"
,
"
online_dial"
,
"
update_firmware"
,
"restart_device"
:
//
case
"key_password"
,
"update_firmware"
,
"restart_device"
:
//
var
data
paraOneString
var
data
paraOneString
if
err
:=
c
.
ShouldBindJSON
(
&
data
);
err
!=
nil
{
if
err
:=
c
.
ShouldBindJSON
(
&
data
);
err
!=
nil
{
logger
.
Log
.
Error
(
"c.ShouldBindJSON(&data)"
,
logger
.
Log
.
Error
(
"c.ShouldBindJSON(&data)"
,
zap
.
String
(
"Src"
,
"case
\"
key_password
\"
,
\"
online_dial
\"
,
\"
update_firmware
\"
,
\"
restart_device
\"
"
),
zap
.
String
(
"Src"
,
"case
\"
key_password
\"
,
\"
update_firmware
\"
,
\"
restart_device
\"
"
),
zap
.
Error
(
err
))
zap
.
Error
(
err
))
sTcpData
.
CtrlCode
=
0
sTcpData
.
CtrlCode
=
0
returnState
=
2002
returnState
=
2002
...
@@ -303,6 +303,23 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
...
@@ -303,6 +303,23 @@ func (dev *DCPhone10) setDevPara(c *gin.Context) {
sTcpData
.
Data
=
[]
byte
(
data
.
Value
)
sTcpData
.
Data
=
[]
byte
(
data
.
Value
)
sTcpData
.
Length
=
byte
(
len
(
data
.
Value
))
sTcpData
.
Length
=
byte
(
len
(
data
.
Value
))
sDevId
=
data
.
DevID
sDevId
=
data
.
DevID
case
"online_dial"
:
var
data
structOnlineDial
if
err
:=
c
.
ShouldBindJSON
(
&
data
);
err
!=
nil
{
logger
.
Log
.
Error
(
"c.ShouldBindJSON(&data)"
,
zap
.
String
(
"Src"
,
"case
\"
online_dial
\"
"
),
zap
.
Error
(
err
))
sTcpData
.
CtrlCode
=
0
returnState
=
2002
returnMsg
=
"参数内容错误"
break
}
sTcpData
.
Data
[
0
]
=
data
.
Value
.
Time
sTcpData
.
Length
=
uint8
(
copy
(
sTcpData
.
Data
[
1
:
],
data
.
Value
.
Number
)
+
1
)
//sTcpData.Data = []byte(data.Value.Number)
//sTcpData.Length = byte(len(data.Value))
sDevId
=
data
.
DevID
break
case
"work_time"
:
// 工作时段
case
"work_time"
:
// 工作时段
var
data
paraWorkTime
var
data
paraWorkTime
if
err
:=
c
.
ShouldBindJSON
(
&
data
);
err
!=
nil
{
if
err
:=
c
.
ShouldBindJSON
(
&
data
);
err
!=
nil
{
...
...
devproduct/dcphone10/dc_phone10_para_json.go
View file @
346879e5
...
@@ -143,3 +143,13 @@ type paraWorkTime struct {
...
@@ -143,3 +143,13 @@ type paraWorkTime struct {
WeekDay
[]
bool
`json:"week_day"`
WeekDay
[]
bool
`json:"week_day"`
}
`json:"value"`
}
`json:"value"`
}
}
type
structOnlineDial
struct
{
DevTime
uint32
`json:"dev_send_time"`
DevID
[]
uint32
`json:"devId"`
Value
struct
{
Result
uint8
`json:"result"`
Time
uint8
`json:"time"`
Number
string
`json:"number"`
}
`json:"value"`
}
devproduct/dcphone10/dc_phone10_tcp.go
View file @
346879e5
...
@@ -50,6 +50,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -50,6 +50,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -69,6 +70,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -69,6 +70,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -87,6 +89,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -87,6 +89,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -114,6 +117,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -114,6 +117,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -202,6 +206,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -202,6 +206,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -223,6 +228,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -223,6 +228,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Data error"
,
logger
.
Log
.
Error
(
"data.Data error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"data.Data[0]"
,
data
.
Data
[
0
]),
zap
.
Uint8
(
"data.Data[0]"
,
data
.
Data
[
0
]),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -233,28 +239,23 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -233,28 +239,23 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
}
}
case
0x30
|
0x80
:
case
0x30
|
0x80
:
type
AutoGenerated
struct
{
jsonStruct
:=
structOnlineDial
{
DevTime
uint32
`json:"dev_send_time"`
DevID
[]
uint32
`json:"devId"`
Value
struct
{
Result
byte
`json:"result"`
Number
string
`json:"number"`
}
`json:"value"`
}
jsonStruct
:=
AutoGenerated
{
data
.
TimeUtc
,
data
.
TimeUtc
,
[]
uint32
{
data
.
DevID
},
[]
uint32
{
data
.
DevID
},
struct
{
struct
{
Result
byte
`json:"result"`
Result
uint8
`json:"result"`
Time
uint8
`json:"time"`
Number
string
`json:"number"`
Number
string
`json:"number"`
}{
}{
data
.
Data
[
0
],
data
.
Data
[
0
],
string
(
data
.
Data
[
1
:
]),
data
.
Data
[
1
],
string
(
data
.
Data
[
2
:
]),
},
},
}
}
x
,
_
:=
json
.
Marshal
(
jsonStruct
)
x
,
_
:=
json
.
Marshal
(
jsonStruct
)
...
@@ -265,6 +266,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -265,6 +266,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
DevTime
:
data
.
TimeUtc
,
DevTime
:
data
.
TimeUtc
,
DevID
:
[]
uint32
{
data
.
DevID
},
DevID
:
[]
uint32
{
data
.
DevID
},
}
}
// todo 第0字节增加模组选择
if
data
.
Data
[
0
]
&
0x03
==
0x03
{
if
data
.
Data
[
0
]
&
0x03
==
0x03
{
jsonStruct
.
Value
.
ResetReason
=
0
// 正常上电
jsonStruct
.
Value
.
ResetReason
=
0
// 正常上电
}
else
if
data
.
Data
[
0
]
==
0x40
{
}
else
if
data
.
Data
[
0
]
==
0x40
{
...
@@ -296,6 +298,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -296,6 +298,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -307,6 +310,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -307,6 +310,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -372,6 +376,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -372,6 +376,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -383,6 +388,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -383,6 +388,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -429,6 +435,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -429,6 +435,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -481,6 +488,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -481,6 +488,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -492,6 +500,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -492,6 +500,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -523,6 +532,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -523,6 +532,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -588,6 +598,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -588,6 +598,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -599,6 +610,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -599,6 +610,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -636,6 +648,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -636,6 +648,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -645,8 +658,10 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -645,8 +658,10 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
}
}
}
}
else
{
}
else
{
data
.
CtrlCode
=
ctrlCode
|
0x80
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -686,6 +701,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -686,6 +701,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
if
json
.
Unmarshal
(
result
,
&
jStruct
)
!=
nil
{
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
logger
.
Log
.
Error
(
"json.Unmarshal err"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -723,6 +739,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -723,6 +739,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
if
jStruct
.
Status
!=
200
{
}
else
if
jStruct
.
Status
!=
200
{
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
logger
.
Log
.
Error
(
"Status != 0 or 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -734,6 +751,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -734,6 +751,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -777,6 +795,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -777,6 +795,7 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
else
{
}
else
{
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
logger
.
Log
.
Error
(
"json.Unmarshal err OR jStruct.Status != 200"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
),
...
@@ -786,8 +805,10 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -786,8 +805,10 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
}
}
}
}
}
else
{
}
else
{
data
.
CtrlCode
=
ctrlCode
|
0x80
//还是回硬件
logger
.
Log
.
Error
(
"data.Length error"
,
logger
.
Log
.
Error
(
"data.Length error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
@@ -795,12 +816,14 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
...
@@ -795,12 +816,14 @@ func (dev *DCPhone10) response(data *tcplongserver.HexData) {
case
0xff
:
// 硬件被动上报异常
case
0xff
:
// 硬件被动上报异常
logger
.
Log
.
Warn
(
"dev up error 0xff"
,
logger
.
Log
.
Warn
(
"dev up error 0xff"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
default
:
default
:
logger
.
Log
.
Error
(
"ctrlCode error"
,
logger
.
Log
.
Error
(
"ctrlCode error"
,
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
String
(
"Src"
,
"TCP-SERVER-response"
),
zap
.
Uint32
(
"DevId"
,
data
.
DevID
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"CtrlCode"
,
ctrlCode
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8
(
"DataLen"
,
data
.
Length
),
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
zap
.
Uint8s
(
"RecvData"
,
data
.
Data
))
...
...
go.mod
View file @
346879e5
...
@@ -20,6 +20,7 @@ require (
...
@@ -20,6 +20,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.18.1 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/dl v0.0.0-20210816190658-eea66df5a73d // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/text v0.3.6 // indirect
...
...
go.sum
View file @
346879e5
...
@@ -77,6 +77,8 @@ go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
...
@@ -77,6 +77,8 @@ go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1 h1:CSUJ2mjFszzEWt4CdKISEuChVIXGBn3lAPwkRGyVrc4=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/dl v0.0.0-20210816190658-eea66df5a73d h1:fY+sw1TVAhVSrszhxX7Ew04Y6V9Znfa8s5O1HTzTsOQ=
golang.org/dl v0.0.0-20210816190658-eea66df5a73d/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
...
...
jeffutil/jeffutil_test.go
View file @
346879e5
...
@@ -24,8 +24,11 @@ func TestHex2Cipher(t *testing.T) {
...
@@ -24,8 +24,11 @@ func TestHex2Cipher(t *testing.T) {
// }
// }
// fmt.Println()
// fmt.Println()
//}
//}
a
:=
[]
byte
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
var
b
[
3
]
byte
str
:=
string
(
a
)
for
i
:=
10002
;
i
<=
11001
;
i
++
{
fmt
.
Println
(
str
)
b
[
0
]
=
byte
(
i
)
fmt
.
Println
(
len
(
str
))
b
[
1
]
=
byte
(
i
>>
8
)
b
[
2
]
=
byte
(
i
>>
16
)
fmt
.
Printf
(
"3D%02X%02X%02X,"
,
b
[
0
],
b
[
1
],
b
[
2
])
}
}
}
log/panic.log
deleted
100644 → 0
View file @
ab1316b4
tcplongserver/jeff_hex_server.go
View file @
346879e5
package
tcplongserver
package
tcplongserver
import
(
import
(
"fmt"
"go.uber.org/zap"
"go.uber.org/zap"
"jeff_workstation_1/jeffutil"
"jeff_workstation_1/jeffutil"
"jeff_workstation_1/logger"
"jeff_workstation_1/logger"
...
@@ -137,7 +136,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
...
@@ -137,7 +136,7 @@ func (s *TCPLongServer) connectionHandle(conn *net.TCPConn, callBack receiveCall
}
}
_
=
conn
.
SetReadDeadline
(
time
.
Time
{})
// 设置回去,但是不知道需不需要这句话
_
=
conn
.
SetReadDeadline
(
time
.
Time
{})
// 设置回去,但是不知道需不需要这句话
_
=
conn
.
Close
()
_
=
conn
.
Close
()
fmt
.
Println
(
"-----------------------------------Out ConnSocketCount:"
,
s
.
ConnSocketCount
)
//
fmt.Println("-----------------------------------Out ConnSocketCount:", s.ConnSocketCount)
}()
}()
//myDevId := -1
//myDevId := -1
//waitTimeOut := 0
//waitTimeOut := 0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment