![]() |
VOOZH | about |
dotnet add package DbcParserLib --version 1.8.0
NuGet\Install-Package DbcParserLib -Version 1.8.0
<PackageReference Include="DbcParserLib" Version="1.8.0" />
<PackageVersion Include="DbcParserLib" Version="1.8.0" />Directory.Packages.props
<PackageReference Include="DbcParserLib" />Project file
paket add DbcParserLib --version 1.8.0
#r "nuget: DbcParserLib, 1.8.0"
#:package DbcParserLib@1.8.0
#addin nuget:?package=DbcParserLib&version=1.8.0Install as a Cake Addin
#tool nuget:?package=DbcParserLib&version=1.8.0Install as a Cake Tool
👁 Continuous Integration
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
Probably the first .NET DBC file parser. Includes packing and unpacking functionality for sending and receiving CAN signals.
Below is a quick preview of the extracted data using a Tesla dbc file taken from commaai/opendbc project:
<br>
DbcParser currently relies on well formatted dbc files as input. Well formatted means that tags are non splitted on several lines or cumulated into a single line. The only multiline support is for comments. This may change in future, but at the moment this is a requirement. As an example of unsupported stuff:
BO_ 1160 DAS_steeringControl: 4 NEO
SG_ DAS_steeringControlType : 23|2@0+
(1,0) [0|0] "" EPAS
VAL_ 1160 DAS_steeringControlType 1 "ANGLE_CONTROL" 3
"DISABLED" 0 "NONE" 2 "RESERVED" ;
Install the library via Nuget Packages and add at the top of your file:
using DbcParserLib;
using DbcParserLib.Model;
<br>
Then to parse a dbc file use the static class Parser, using one oth the parsing flavours:
Dbc dbc = Parser.ParseFromPath("C:\\your_dbc_file.dbc");
Dbc dbc = Parser.ParseFromStream(File.OpenRead("C:\\your_dbc_file.dbc")); // Or a stream from network
Dbc dbc = Parser.Parse("a dbc as string");
<br>
Dbc objectThe Dbc object contains two collections, Messages and Nodes, both are IEnumerable<T> so can be accessed, iterated and queried using standard LINQ.
As an example, take all messages with id > 100 and more than 2 signals:
var filteredSelection = dbc
.Messages
.Where(m => m.ID > 100 && m.Signals.Count > 2)
.ToArray();
<br>
errors managementFrom v1.4.0 parsing errors management has been introduced to inform users about syntax errors occurred during parsing procedure.
The IParseFailureObserver interface provides all methods to handle syntax errors, like:
;, ', , missing)The library comes with two different implementations:
SilentFailureObserver: the default one. It silently swallow errors when parsingSimpleFailureObserver: simple observer that logs any error. SimpleFailureObserver errors list:
Unknown sintax: there is no corresponding TAG<sup>1</sup> sintaxSyntax error: syntax error for a specific TAGDuplicated object<sup>2</sup>: the parser found (and ignores) a dulicated objectNot found: an object is declared or referenced before its definitionout of bound: the value assigned to a property is lower/greater with respect to the minimum/maximum value declared in the property definitionout of index: the declared index is an unacceptable value (for properties that support access to the value via index, e.g. enum value)Errors list can be retrieve through GetErrorList() method, like in the example below
// Comment this two lines to remove errors parsing management (errors will be silent)
// You can provide your own IParseFailureObserver implementation to customize errors parsing management
var failureObserver = new SimpleFailureObserver();
Parser.SetParsingFailuresObserver(failureObserver);
var dbc = Parser.ParseFromPath(filePath);
var errors = failureObserver.GetErrorList();
The user is free to create its own implementation to customize error management.
<sup>1</sup>TAG: BA_, BA_DEF_, BA_DEF_DEF_, BO_, BU_, CM_, EV_, ENVVAR_DATA_, SIG_VALTYPE_ SG_, VAL_, VAL_TABLE_
<br>
<sup>2</sup>Object: Node, Message, Signal, Property, Environment variable, Value table
<br>
To pack and unpack signals you can use static class Packer
Example for packing/unpacking a signal: 14 bits, Min: -61.92, Max: 101.91
Signal sig = new Signal
{
sig.Length = 14,
sig.StartBit = 2,
sig.IsSigned = 1,
sig.ByteOrder = 1, // 0 = Big Endian (Motorola), 1 = Little Endian (Intel)
sig.Factor = 0.01,
sig.Offset = 20
};
// This packs the signal for sending
ulong TxMsg = Packer.TxSignalPack(-34.3, sig);
// This unpacks a received signal and calculates the corresponding engineering value
double val = Packer.RxSignalUnpack(TxMsg, sig);
Multiple signals can be packed before CAN transmission using:
ulong TxMsg = 0;
TxMsg |= Packer.TxSignalPack(value1, sig1);
TxMsg |= Packer.TxSignalPack(value2, sig2);
TxMsg |= Packer.TxSignalPack(value3, sig3);
// ...
// Send TxMsg on CAN
The user needs to make sure that the signals do not overlap with each other by properly specifying the Length and StartBit.
A message can contain multiplexed data, i.e. layout can change depending on a multiplexor value. The Packer class is unaware of multiplexing, so it's up to the user to check that the given message actually contains the signal.
As an example, consider the following dbc lines:
BO_ 568 UI_driverAssistRoadSign: 8 GTW
SG_ UI_roadSign M : 0|8@1+ (1,0) [0|0] "" DAS
SG_ UI_dummyData m0 : 8|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ UI_stopSignStopLineDist m1 : 8|10@1+ (0.25,-8) [-8|247.5] "m" Vector__XXX
Signal UI_dummyData will only be available when UI_roadSign value is 0 while UI_stopSignStopLineDist will only be available when UI_roadSign value is 1.
You can access multiplexing information calling
var multiplexingInfo = signal.MultiplexingInfo();
if(multiplexingInfo.Role == MultiplexingRole.Multiplexor)
{
// This is a multiplexor!
}
else if(multiplexingInfo.Role == MultiplexingRole.Multiplexed)
{
Console.WriteLine($"This signal is multiplexed and will be available when multiplexor value is {multiplexingInfo.Group}");
}
You can also check is a message does contain multiplexed signals by calling the extension method
if(message.IsMultiplexed())
{
// ...
}
<br>
Below you can find a list of obsolete stuff that are going to be removed in the future releases.
| Class | Property/Method | Obsolete | Removed | Replaced by | Comment |
|---|---|---|---|---|---|
| Signal | IsSigned | v1.3.0 | v1.5.0 | ValueType |
Byte property replaced by DbcValueType property which provides <br> more informations about signal type |
| Signal | ValueTable | v1.3.0 | v1.5.0 | ValueTableMap |
String property replaced by a IDictionary<int,string> property |
| Signal | ToPairs() | v1.3.0 | v1.4.2 | - | Extension method used to convert ValueTable into ValueTableMap |
| Message | CycleTime | v1.4.2 | 1.6.0 | bool CycleTime(out int cycleTime) |
CycleTime is no more a message property (replaced by an extension method) |
<br>
Contributions are appreciated! Feel free to create pull requests to improve this library.
This project is supported by JetBrains for Open Source development
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on DbcParserLib:
| Package | Downloads |
|---|---|
|
Ahsoka.Extensions.Can
Data Service Extension for OpenPV 5.0 // 60f365e6af3b712659435adb8e2f8c34e4c7c2f5 - OpenPV_Extension_Info { "extensionName": "CAN Service Extension", "packageName": "Ahsoka.Extensions.Can", "uxpackageName": "Ahsoka.Extensions.Can.UX", "uxViewModelName": "CanSetupViewModel", "sdkGeneratorName": "CanCodeGenerator", "serviceConfigurations": [ { "socketType": "TcpSocket", "serviceName": "CanService", "tcpListenAddress": "localhost", "tcpConnectionAddress": "localhost", "dataChannel": 6107, "configurationFile": "CanService.cancalibration.json", "behaviors": "AutoStart" } ], "hasCommands": "true", "hasUx": "true", "hasSdkGenerator": "true" } |
|
|
Ahsoka.Core.Can
Package Description |
|
|
Ahsoka.Extensions.Control
Data Service Extension for OpenPV 5.0 // 60f365e6af3b712659435adb8e2f8c34e4c7c2f5 - OpenPV_Extension_Info { "extensionName": "Control Service Extension", "packageName": "Ahsoka.Extensions.Control", "uxpackageName": "Ahsoka.Extensions.Control.UX", "serviceConfigurations": [ { "socketType": "TcpSocket", "serviceName": "CanService", "tcpListenAddress": "localhost", "tcpConnectionAddress": "localhost", "dataChannel": 6107, "configurationFile": "CanService.cancalibration.json", "behaviors": "AutoStart" }, { "socketType": "TcpSocket", "serviceName": "IOService", "tcpListenAddress": "localhost", "tcpConnectionAddress": "localhost", "dataChannel": 6106, "behaviors": "AutoStart" } ] } |
|
|
RegnoDecoder.CAN
This package facilitates the conversion of CAN dbc and trace files |
|
|
SignalCandy.Core
Core library for SignalCandy: DBC parsing, config validation, and C99 code generation utilities. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.8.0 | 6,237 | 1/9/2026 |
| 1.7.0 | 34,089 | 9/6/2024 |
| 1.6.1 | 2,544 | 7/26/2024 |
| 1.6.0 | 4,561 | 4/15/2024 |
| 1.5.0 | 8,158 | 11/6/2023 |
| 1.4.2 | 449 | 10/19/2023 |
| 1.4.1 | 265 | 10/19/2023 |
| 1.4.0 | 573 | 9/27/2023 |
| 1.3.3 | 392 | 9/15/2023 |
| 1.3.2 | 314 | 9/11/2023 |
| 1.3.1 | 7,900 | 4/14/2023 |
| 1.3.0 | 1,854 | 3/25/2023 |
| 1.2.0 | 4,296 | 10/28/2022 |
| 1.0.7 | 781 | 9/30/2022 |
| 1.0.6 | 844 | 8/31/2022 |
| 1.0.5 | 995 | 3/8/2022 |
| 1.0.4 | 660 | 1/17/2022 |
| 1.0.3 | 472 | 1/3/2022 |
| 1.0.2 | 473 | 12/30/2021 |
| 1.0.1 | 469 | 12/30/2021 |