Coder Social home page Coder Social logo

报文解析错误 about jt-framework HOT 2 CLOSED

hylexus avatar hylexus commented on June 30, 2024
报文解析错误

from jt-framework.

Comments (2)

pruidong avatar pruidong commented on June 30, 2024

原因为: 在报文中间出现了7E,但框架截取了前面半部分,漏掉了后面半部分.导致异常发生.

from jt-framework.

pruidong avatar pruidong commented on June 30, 2024

检查后,发现我在0200位置上报处理方法内获取到的报文是被框架处理过的.

如果需要原始报文,则需要自定义解码器来实现.

感谢 @hylexus 提供实现代码.

实现代码如下:

/**
 * 自定义解码器
 *
 * <p>备注: (主要用于将原始报文,传递至后续流程[官方原有流程为: 将修改后的报文传递至后续流程])
 *
 * @author 
 * @version 2022/9/10
 */
@Component
public class CustomJt808MsgDecoder extends DefaultJt808MsgDecoder {

  public CustomJt808MsgDecoder(
      Jt808MsgTypeParser msgTypeParser,
      Jt808MsgBytesProcessor msgBytesProcessor,
      Jt808ProtocolVersionDetectorRegistry versionDetectorRegistry) {
    super(msgTypeParser, msgBytesProcessor, versionDetectorRegistry);
  }

  @Override
  public Jt808Request decode(ByteBuf byteBuf) {
    final ByteBuf copy = byteBuf.copy();
    final Jt808Request request = super.decode(byteBuf);
    return request.mutate().rawByteBuf(copy).build();
  }
}

from jt-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.