Validated CAN DBC parser and signal codec toolkit for MoonBit
let database = @dbc.parse_dbc(dbc_text).unwrap()
let frame = @dbc.encode_frame(
database,
100,
[@dbc.SignalAssignment::new("Speed", 12.34)],
).unwrap()
let decoded = @dbc.decode_frame(database, frame).unwrap()
println(@dbc.render_decoded_text(decoded.message(), decoded.signals()))pub struct DbcAudit {
database_value : DbcDatabase
validation_value : DbcValidationResult
statistics_value : DbcStatistics
canonical_text_value : String
round_trip_consistent_value : Bool
} derive(Eq, Debug)pub struct DbcBatchItem {
label_value : String
database_value : DbcDatabase?
error_value : DbcError?
} derive(Eq, Debug)pub struct DbcBatchResult {
items_value : Array[DbcBatchItem]
accepted_value : Int
rejected_value : Int
total_input_bytes_value : Int
total_messages_value : Int
total_signals_value : Int
} derive(Eq, Debug)pub struct DbcComparison {
message_changes_value : Array[MessageChange]
signal_changes_value : Array[SignalChange]
breaking_change_count_value : Int
} derive(Eq, Debug)fn DbcDatabase::new(version : String, nodes : Array[DbcNode], messages : Array[DbcMessage], ignored_statement_count? : Int) -> DbcDatabasepub struct DbcError {
code_value : String
message_value : String
location_value : SourceLocation
context_value : String
} derive(Eq, Debug)fn DbcError::new(code : DbcErrorCode, message : String, line : Int, column : Int, context? : String) -> DbcErrorpub(all) enum DbcErrorCode {
EmptyInput
InputLimitExceeded
LineLimitExceeded
InvalidSyntax
InvalidInteger
InvalidNumber
InvalidIdentifier
InvalidMessage
InvalidSignal
InvalidValueTable
DuplicateMessageId
DuplicateMessageName
DuplicateSignalName
UnknownMessage
UnknownSignal
InvalidBitRange
InvalidDataLength
ValueOutOfRange
OverlappingSignal
UnsupportedConstruct
} derive(Eq, Debug)fn DbcMessage::new(id : Int, name : String, size : Int, transmitter : String, signals : Array[DbcSignal], source_line? : Int) -> DbcMessagepub(all) struct DbcParseLimits {
max_input_bytes : Int
max_lines : Int
max_messages : Int
max_signals_per_message : Int
max_nodes : Int
}pub struct DbcSignal {
name_value : String
start_bit_value : Int
bit_length_value : Int
byte_order_value : ByteOrder
value_type_value : SignalValueType
factor_value : Double
offset_value : Double
minimum_value : Double
maximum_value : Double
unit_value : String
receivers_value : Array[String]
values_value : Array[DbcValueDescription]
comment_value : String
source_line_value : Int
} derive(Eq, Debug)fn DbcSignal::new(name : String, start_bit : Int, bit_length : Int, byte_order : ByteOrder, value_type : SignalValueType, factor : Double, offset : Double, minimum : Double, maximum : Double, unit : String, receivers : Array[String], source_line? : Int) -> DbcSignalpub struct DbcStatistics {
node_count_value : Int
message_count_value : Int
signal_count_value : Int
classic_message_count_value : Int
fd_message_count_value : Int
intel_signal_count_value : Int
motorola_signal_count_value : Int
signed_signal_count_value : Int
described_value_count_value : Int
payload_bytes_value : Int
node_traffic_value : Array[NodeTraffic]
} derive(Eq, Debug)pub struct DbcValidationIssue {
severity_value : ValidationSeverity
code_value : String
message_value : String
message_id_value : Int?
signal_name_value : String?
source_line_value : Int
} derive(Eq, Debug)pub(all) struct DbcValidationPolicy {
allow_extended_ids : Bool
allow_can_fd : Bool
require_known_nodes : Bool
detect_signal_overlap : Bool
warn_empty_units : Bool
}pub struct DbcValidationResult {
issues_value : Array[DbcValidationIssue]
error_count_value : Int
warning_count_value : Int
} derive(Eq, Debug)pub struct DecodedFrame {
frame_value : CanFrame
message_value : DbcMessage
signals_value : Array[DecodedSignal]
} derive(Eq, Debug)pub struct FrameBatchItem {
index_value : Int
frame_value : CanFrame
decoded_value : DecodedFrame?
error_value : DbcError?
} derive(Eq, Debug)pub struct FrameBatchResult {
items_value : Array[FrameBatchItem]
accepted_value : Int
rejected_value : Int
total_data_bytes_value : Int
message_counts_value : Array[MessageFrameCount]
} derive(Eq, Debug)fn FrameBatchResult::find_message_count(self : FrameBatchResult, message_id : Int) -> MessageFrameCount?pub struct MessageChange {
kind_value : ChangeKind
message_id_value : Int
message_name_value : String
detail_value : String
breaking_value : Bool
} derive(Eq, Debug)pub(all) struct MessageFilter {
transmitter : String?
receiver : String?
name_contains : String?
minimum_size : Int?
maximum_size : Int?
}pub struct SignalChange {
kind_value : ChangeKind
message_id_value : Int
signal_name_value : String
detail_value : String
breaking_value : Bool
} derive(Eq, Debug)fn audit_dbc(text : String, limits? : DbcParseLimits, policy? : DbcValidationPolicy) -> Result[DbcAudit, DbcError]fn decode_frame_batch(database : DbcDatabase, frames : Array[CanFrame], max_frames? : Int, max_total_data_bytes? : Int) -> Result[FrameBatchResult, DbcError]fn decode_frame_hex(database : DbcDatabase, message_id : Int, hex_data : String) -> Result[DecodedFrame, DbcError]fn decode_signal(message : DbcMessage, signal : DbcSignal, data : Bytes) -> Result[DecodedSignal, DbcError]fn encode_frame(database : DbcDatabase, message_id : Int, assignments : Array[SignalAssignment]) -> Result[CanFrame, DbcError]fn encode_message(message : DbcMessage, assignments : Array[SignalAssignment]) -> Result[Bytes, DbcError]fn encode_physical_signal(message : DbcMessage, signal : DbcSignal, physical : Double, data : Array[Byte], tolerance? : Double) -> Result[Unit, DbcError]fn encode_signed_raw_signal(message : DbcMessage, signal : DbcSignal, raw : Int64, data : Array[Byte]) -> Result[Unit, DbcError]fn encode_unsigned_raw_signal(message : DbcMessage, signal : DbcSignal, raw : UInt64, data : Array[Byte]) -> Result[Unit, DbcError]fn parse_dbc_batch(inputs : Array[DbcBatchInput], max_items? : Int, max_total_bytes? : Int, limits? : DbcParseLimits) -> Result[DbcBatchResult, DbcError]fn rename_message(database : DbcDatabase, id : Int, after : String) -> Result[DbcDatabase, DbcError]fn rename_node(database : DbcDatabase, before : String, after : String) -> Result[DbcDatabase, DbcError]fn rename_signal(database : DbcDatabase, message_id : Int, before : String, after : String) -> Result[DbcDatabase, DbcError]fn select_database_messages(database : DbcDatabase, ids : Array[Int]) -> Result[DbcDatabase, DbcError]Install
Download zipValidated CAN DBC parser and signal codec toolkit for MoonBit