Open fxk2006 opened 1 day ago
可能是老版本的有问题 目前用最新版本的这个报文是正常的
package main
import (
"encoding/hex"
"fmt"
"github.com/cuteLittleDevil/go-jt808/protocol/jt808"
"github.com/cuteLittleDevil/go-jt808/protocol/model"
)
func main() {
msg := "7e010000300000000015580001001f006e63643132337777772e3830382e636f6d0000000000000000003736353433323101b2e2413132333435363738357e"
jtMsg := jt808.NewJTMessage()
data, _ := hex.DecodeString(msg)
fmt.Println(jtMsg.Decode(data))
var t0x100 model.T0x0100
fmt.Println(t0x100.Parse(jtMsg))
fmt.Println(t0x100.String())
}
1、使用您模拟器example/simulator/client/main.go 2、发送注册请求0x0100时,报"body length inconsistency" 原始报文:7e010000300000000015580001001f006e63643132337777772e3830382e636f6d0000000000000000003736353433323101b2e2413132333435363738357e 问题定位:jt808.go第98行,打印出来的start=12,j.Header.Property.BodyDayaLen=48,end+1=61,len(escapeData) =85问题定位:jt808.go第98行,打印出来的start=12,j.Header.Property.BodyDayaLen=48,end+1=61,len(escapeData) =85
模拟器 example/simulator/client/main.go 这个我直接在本机跑也是没问题的
type meRegister struct {
model.T0x0100
}
func (m meRegister) OnReadExecutionEvent(message service.Message) { fmt.Println("注册信息", message.Header.TerminalPhoneNo) var t0x0100 model.T0x0100 fmt.Println(t0x0100.Parse(message.JTMessage)) fmt.Println(t0x0100.String()) }
func (m *meRegister) OnWriteExecutionEvent(message service.Message) {}
func init() { goJt808 := service.New( service.WithHostPorts("0.0.0.0:8080"), service.WithNetwork("tcp"), service.WithCustomHandleFunc(func() map[consts.JT808CommandType]service.Handler { return map[consts.JT808CommandType]service.Handler{ consts.T0100Register: &meRegister{}, } }), ) go goJt808.Run() }
3. 在本机跑 使用的是默认的go mod
https://github.com/cuteLittleDevil/go-jt808/blob/main/example/simulator/go.mod
``` shell
go build
./client -ip=192.168.31.231 -max=2
1、使用您模拟器example/simulator/client/main.go 2、发送注册请求0x0100时,报"body length inconsistency" 原始报文:7e010000300000000015580001001f006e63643132337777772e3830382e636f6d0000000000000000003736353433323101b2e2413132333435363738357e 问题定位:jt808.go第98行,打印出来的start=12,j.Header.Property.BodyDayaLen=48,end+1=61,len(escapeData) =85