cuteLittleDevil / go-jt808

jt808服务端 单机[2核4G]并发10w+ 100%测试覆盖率 有多种例子支持二次开发(每日保存亿+经纬度[2核4G] 平台下发数据获取回复 报文详细解析 JT1078流媒体播放等)
MIT License
14 stars 9 forks source link

报文解析问题 #1

Open fxk2006 opened 1 day ago

fxk2006 commented 1 day ago

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

image

cuteLittleDevil commented 1 day ago
c6c0adfe2962971ae7f287afeeec81b1

可能是老版本的有问题 目前用最新版本的这个报文是正常的

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())
}
cuteLittleDevil commented 1 day ago

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

image

模拟器 example/simulator/client/main.go 这个我直接在本机跑也是没问题的

  1. 在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 iShot_2024-11-13_20 25 30