Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 1838763

Browse files
committed
test port协议一致
1 parent b963fc4 commit 1838763

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

SerialHandle/SerialHandle.go

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func SerialSendCmd(act uint8, variable datapack.VariableT) error {
104104
}
105105

106106
func verifyBuff(buff []byte) (int, []byte) {
107-
log.Println(buff)
108107
if len(buff) < 19 {
109108
log.Println("Data pack too short")
110109
return 0, nil

SerialHandle/TestPort.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,24 @@ func testValue(x float64, addr uint32) float64 {
5353

5454
func (tp *testPort) Read(p []byte) (n int, err error) {
5555
addresses := tp.readingAddresses
56-
maxNumPack := len(p) / 16
56+
maxNumPack := len(p) / 20
5757
if len(addresses) > maxNumPack {
5858
addresses = addresses[:maxNumPack]
5959
}
6060

6161
for i, addr := range addresses {
62-
s := p[16*i : 16*(i+1)]
62+
s := p[20*i : 20*(i+1)]
6363
s[0] = 1 // board
6464
s[1] = 2 // ???
6565
s[2] = 8 // typeLen
6666
copy(s[3:7], datapack.AnyToBytes(addr))
6767
x := time.Now().Sub(tp.createdTime).Seconds()
6868
y := testValue(x, addr)
6969
copy(s[7:15], datapack.AnyToBytes(y))
70-
s[15] = '\n'
70+
copy(s[15:19], datapack.AnyToBytes(uint32(x)))
71+
s[19] = '\n'
7172
}
72-
return len(addresses) * 16, nil
73+
return len(addresses) * 20, nil
7374
}
7475

7576
func (tp *testPort) Write(p []byte) (n int, err error) {

0 commit comments

Comments
 (0)