AUTOSAR SOME/IP container: Java parsing library

KS implementation details

License: CC0-1.0
Minimal Kaitai Struct required: 0.9

This page hosts a formal specification of AUTOSAR SOME/IP container using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

Usage

Runtime library

All parsing code for Java generated by Kaitai Struct depends on the Java runtime library. You have to install it before you can parse data.

The Java runtime library is published in the Maven Central Repository. Refer to the artifact page for instructions how to add it into your project with the build tool that you use.

Code

Parse a local file and get structure in memory:

SomeIpContainer data = SomeIpContainer.fromFile("path/to/local/file.bin");

Or parse structure from a byte array:

byte[] someArray = new byte[] { ... };
SomeIpContainer data = new SomeIpContainer(new ByteBufferKaitaiStream(someArray));

After that, one can get various attributes from the structure by invoking getter methods like:

data.someIpPackages() // => get some ip packages

Java source code to parse AUTOSAR SOME/IP container

SomeIpContainer.java

// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild

import io.kaitai.struct.ByteBufferKaitaiStream;
import io.kaitai.struct.KaitaiStruct;
import io.kaitai.struct.KaitaiStream;
import java.io.IOException;
import java.util.ArrayList;

public class SomeIpContainer extends KaitaiStruct {
    public static SomeIpContainer fromFile(String fileName) throws IOException {
        return new SomeIpContainer(new ByteBufferKaitaiStream(fileName));
    }

    public SomeIpContainer(KaitaiStream _io) {
        this(_io, null, null);
    }

    public SomeIpContainer(KaitaiStream _io, KaitaiStruct _parent) {
        this(_io, _parent, null);
    }

    public SomeIpContainer(KaitaiStream _io, KaitaiStruct _parent, SomeIpContainer _root) {
        super(_io);
        this._parent = _parent;
        this._root = _root == null ? this : _root;
        _read();
    }
    private void _read() {
        this.someIpPackages = new ArrayList<SomeIp>();
        {
            int i = 0;
            while (!this._io.isEof()) {
                this.someIpPackages.add(new SomeIp(this._io));
                i++;
            }
        }
    }
    private ArrayList<SomeIp> someIpPackages;
    private SomeIpContainer _root;
    private KaitaiStruct _parent;
    public ArrayList<SomeIp> someIpPackages() { return someIpPackages; }
    public SomeIpContainer _root() { return _root; }
    public KaitaiStruct _parent() { return _parent; }
}