A Go library to handle AUTOSAR DLT (Diagnostic Log and Trace) protocol, based on AUTOSAR Specification of Diagnostic Log and Trace V1.2.0 R4.0 Rev3, Section 7.7 Protocol Specification.
- Parse DLT messages from files
- Create and write DLT messages to files
- Support for both verbose and non-verbose modes
- Support for various argument types (String, Raw, Numeric types)
- Support for DLT headers (Storage, Standard, and Extended)
go get github.com/mukangt/godltpackage main
import (
"github.com/mukangt/godlt/header"
"github.com/mukangt/godlt/message"
"github.com/mukangt/godlt/payload"
"github.com/mukangt/godlt/file"
)
func main() {
// Create DLT message
arguments := []payload.Argument{
payload.NewArgumentString("hello, godlt!"),
}
ecuID := "Ecu"
sessionID := uint32(12345)
timestamp := uint32(93678)
storageHeader := header.NewStorageHeader(0, 0, "ECU")
msg1 := message.CreateVerboseMessage(
arguments,
header.DLTTypeLog,
header.MessageTypeInfo(header.DLTLogInfo),
"App",
"Ctx",
×tamp,
&sessionID,
&ecuID,
0, // message counter
1, // version number
true, // msb first
storageHeader,
)
msg2 := message.CreateNonVerboseMessage(
0,
[]byte{0x01, 0x02, 0x03},
nil, // extended header
×tamp,
&sessionID,
&ecuID,
1, // message counter
1, // version number
true, // msb first
storageHeader,
)
// Write DLT messages to file
writer, _ := file.NewDltFileWriter("example.dlt", false)
defer writer.Close()
writer.WriteMessages([]*message.DltMessage{msg1, msg2})
}package main
import (
"fmt"
"github.com/mukangt/godlt/file"
)
func main() {
// Read DLT messages from file
reader, _ := file.NewDltFileReader("example.dlt", "")
defer reader.Close()
messages, _ := reader.ReadMessages()
// Print overview of each DLT message
for _, msg := range messages {
fmt.Println(msg.String())
}
}package main
import (
"fmt"
"github.com/mukangt/godlt/message"
)
func main() {
// Assume you have DLT message bytes from some source
var messageBytes []byte // This would come from a file, network, etc.
// Parse the message from bytes
// Set the second parameter to true if the bytes include a storage header
// Set the third parameter to specify encoding (empty string for default)
msg, err := message.CreateFromBytes(messageBytes, false, "")
if err != nil {
// Handle error
panic(err)
}
// Use the parsed message
fmt.Println(msg.String())
}- Storage Header
- Standard Header
- Extended Header
- Non-verbose payload
- Verbose payload
- String arguments
- Raw data arguments
- Numeric arguments (UInt8, UInt16, UInt32, UInt64, SInt8, SInt16, SInt32, SInt64)
- Boolean arguments
- Floating point arguments (Float32, Float64)
- Array arguments (not supported)
- Struct arguments (not supported)
- Fixed point arguments (not supported)
- Trace info arguments (not supported)
- Variable info arguments (not supported)
MIT