Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Credit go to @Lundin for pointing me in the right direction. Kvaser has a CAN SDK free of charge. I added this to my VS22 C# project by adding "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser...
Answer
#10: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- **EDIT:**\
- (Vector CANdb++) If you get unspecified syntax errors: make sure all message/signal names start with a letter and contain only letters, numbers and underscore!
- (Vector CANdb++) If you get the error: "unknown symbol newly defined" make sure your are not defining two messages with e.g. the same ID.
- If you want to live debug human readable J1939 messages, with offsets included, use [Busmaster](https://rbei-etas.github.io/busmaster/), it can convert the DBC file to DBF and then use the DBF to interpret the messages.
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
// This part sometimes gave me errors when opening with Vector leaving it out did not make a difference for me.- //kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd //VFrameFormat_attr);
- //kv.SetAttributeDefinitionType(VFrameFormat_attr, //kv.AttributeType.AttributeEnumeration);
- //kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- //kv.SetAttributeDefinitionOwner(VFrameFormat_attr, //kv.AttributeOwner.AttributeOwnerMessage);
- //for (int i = 0; i < 4; i++)
- //kv.SetAttributeDefinitionString(VFrameFormat_attr, //VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- **EDIT:**\
- (Vector CANdb++) If you get unspecified syntax errors: make sure all message/signal names start with a letter and contain only letters, numbers and underscore!
- (Vector CANdb++) If you get the error: "unknown symbol newly defined" make sure your are not defining two messages with e.g. the same ID.
- If you want to live debug human readable J1939 messages, with offsets included, use [Busmaster](https://rbei-etas.github.io/busmaster/), it can convert the DBC file to DBF and then use the DBF to interpret the messages.
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- // This part sometimes gave me errors when opening with Vector's CANdb++ or Kvaser's database editor 3, leaving it out did not make a difference for me.
- //kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd //VFrameFormat_attr);
- //kv.SetAttributeDefinitionType(VFrameFormat_attr, //kv.AttributeType.AttributeEnumeration);
- //kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- //kv.SetAttributeDefinitionOwner(VFrameFormat_attr, //kv.AttributeOwner.AttributeOwnerMessage);
- //for (int i = 0; i < 4; i++)
- //kv.SetAttributeDefinitionString(VFrameFormat_attr, //VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#9: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
**EDIT:**If you get unspecified syntax errors: make sure all message/signal names start with a letter and contain only letters, numbers and underscore!If you get the error: "unknown symbol newly defined" make sure your are not defining two messages with e.g. the same ID.- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);for (int i = 0; i < 4; i++)kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- **EDIT:**\
- (Vector CANdb++) If you get unspecified syntax errors: make sure all message/signal names start with a letter and contain only letters, numbers and underscore!
- (Vector CANdb++) If you get the error: "unknown symbol newly defined" make sure your are not defining two messages with e.g. the same ID.
- If you want to live debug human readable J1939 messages, with offsets included, use [Busmaster](https://rbei-etas.github.io/busmaster/), it can convert the DBC file to DBF and then use the DBF to interpret the messages.
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- // This part sometimes gave me errors when opening with Vector leaving it out did not make a difference for me.
- //kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd //VFrameFormat_attr);
- //kv.SetAttributeDefinitionType(VFrameFormat_attr, //kv.AttributeType.AttributeEnumeration);
- //kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- //kv.SetAttributeDefinitionOwner(VFrameFormat_attr, //kv.AttributeOwner.AttributeOwnerMessage);
- //for (int i = 0; i < 4; i++)
- //kv.SetAttributeDefinitionString(VFrameFormat_attr, //VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#8: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
**If you get unspecified syntax errors remove non-text characters from signal names!****If you get the error: "unknown symbol newly defined" make sure your are nto defining 2 messages with e.g. the same ID.**
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- **EDIT:**
- If you get unspecified syntax errors: make sure all message/signal names start with a letter and contain only letters, numbers and underscore!
- If you get the error: "unknown symbol newly defined" make sure your are not defining two messages with e.g. the same ID.
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#7: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
**If you get unspecified syntax errors remove non-text characters from signal names!**
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- **If you get unspecified syntax errors remove non-text characters from signal names!**
- **If you get the error: "unknown symbol newly defined" make sure your are nto defining 2 messages with e.g. the same ID.**
#6: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- **If you get unspecified syntax errors remove non-text characters from signal names!**
#5: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
//for (int i = 0; i < 4; i++)//kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]); // this line causes kv.WriteFile() to throw an accessviolationexception, except on the first time. I have no idea why :(- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i], i);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#4: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
for (int i = 0; i < 4; i++)kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]);- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- //for (int i = 0; i < 4; i++)
- //kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]); // this line causes kv.WriteFile() to throw an accessviolationexception, except on the first time. I have no idea why :(
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#3: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
kv.SetSignalEncoding(sigHnd, kv.SignalEncoding.Intel);- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, encoding);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#2: Post edited
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where you executable is).I ported an .C example application to C# and it seems to work:- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, kv.SignalEncoding.Intel);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
- Credit go to @Lundin for pointing me in the right direction.
- Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll"
- and
- "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references.
- AND (this I was stuck on)
- Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where your executable is).
- I ported a C example application from Kvaser to C# and it seems to work:
- ```
- using kv = Kvaser.KvadbLib.Kvadblib;
- List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" };
- void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd)
- {
- kv.AddMsg(dbHnd, out msgHnd);
- kv.SetMsgName(msgHnd, msgName);
- kv.SetMsgDlc(msgHnd, dlc);
- kv.SetMsgIdEx(msgHnd, msgID);
- kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939);
- }
- void add_sig_to_msg
- (
- kv.MessageHnd msgHnd,
- string sigName,
- string comment,
- string unit,
- kv.SignalEncoding encoding,
- kv.SignalType type,
- byte startBit,
- byte length,
- double minVal,
- double maxVal,
- out kv.SignalHnd sigHnd
- )
- {
- kv.AddSignal(msgHnd, out sigHnd);
- kv.SetSignalName(sigHnd, sigName);
- kv.SetSignalComment(sigHnd, comment);
- kv.SetSignalUnit(sigHnd, unit);
- kv.SetSignalEncoding(sigHnd, kv.SignalEncoding.Intel);
- kv.SetSignalRepresentationType(sigHnd, type);
- kv.SetSignalValueSize(sigHnd, startBit, length);
- kv.SetSignalValueLimits(sigHnd, minVal, maxVal);
- }
- kv.Open(out kv.Hnd dbHnd);
- kv.Create(dbHnd, "local", null);
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr);
- kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString);
- kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType");
- kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb);
- kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939");
- kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr);
- kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration);
- kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat");
- kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage);
- for (int i = 0; i < 4; i++)
- kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]);
- add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand);
- add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd);
- kv.WriteFile(dbHnd, "./testDBC.dbc");
- ```
#1: Initial revision
Credit go to @Lundin for pointing me in the right direction. Kvaser has a [CAN SDK](https://www.kvaser.com/developer/canlib-sdk/) free of charge. I added this to my VS22 C# project by adding "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll" and "...\Kvaser\Canlib\dotnet\x64\netstandard2.0\Kvaser.CanLib.dll" to my project references. AND (this I was stuck on) Copying "...\Kvaser\Canlib\bin_x64\kvaDbLib.dll" to your application folder (where you executable is). I ported an .C example application to C# and it seems to work: ``` using kv = Kvaser.KvadbLib.Kvadblib; List<string> VFrameFormat_enum_names = new() { "StandardCAN", "ExtendedCAN", "reserved", "J1939PG" }; void add_msg_to_db(kv.Hnd dbHnd, string msgName, int dlc, int msgID, out kv.MessageHnd msgHnd) { kv.AddMsg(dbHnd, out msgHnd); kv.SetMsgName(msgHnd, msgName); kv.SetMsgDlc(msgHnd, dlc); kv.SetMsgIdEx(msgHnd, msgID); kv.SetMsgFlags(msgHnd, kv.MESSAGE.J1939); } void add_sig_to_msg ( kv.MessageHnd msgHnd, string sigName, string comment, string unit, kv.SignalEncoding encoding, kv.SignalType type, byte startBit, byte length, double minVal, double maxVal, out kv.SignalHnd sigHnd ) { kv.AddSignal(msgHnd, out sigHnd); kv.SetSignalName(sigHnd, sigName); kv.SetSignalComment(sigHnd, comment); kv.SetSignalUnit(sigHnd, unit); kv.SetSignalEncoding(sigHnd, kv.SignalEncoding.Intel); kv.SetSignalRepresentationType(sigHnd, type); kv.SetSignalValueSize(sigHnd, startBit, length); kv.SetSignalValueLimits(sigHnd, minVal, maxVal); } kv.Open(out kv.Hnd dbHnd); kv.Create(dbHnd, "local", null); kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd ProtocolType_attr); kv.SetAttributeDefinitionType(ProtocolType_attr, kv.AttributeType.AttributeString); kv.SetAttributeDefinitionName(ProtocolType_attr, "ProtocolType"); kv.SetAttributeDefinitionOwner(ProtocolType_attr, kv.AttributeOwner.AttributeOwnerDb); kv.SetAttributeDefinitionString(ProtocolType_attr, "J1939"); kv.AddAttributeDefinition(dbHnd, out kv.AttributeDefHnd VFrameFormat_attr); kv.SetAttributeDefinitionType(VFrameFormat_attr, kv.AttributeType.AttributeEnumeration); kv.SetAttributeDefinitionName(VFrameFormat_attr, "VFrameFormat"); kv.SetAttributeDefinitionOwner(VFrameFormat_attr, kv.AttributeOwner.AttributeOwnerMessage); for (int i = 0; i < 4; i++) kv.SetAttributeDefinitionString(VFrameFormat_attr, VFrameFormat_enum_names[i]); add_msg_to_db(dbHnd, "TEST_MSG_000", 8, 0xC0FFEE, out kv.MessageHnd msgHand); add_sig_to_msg(msgHand, "TEST_SIG_000", "I am a comment", "banana", kv.SignalEncoding.Intel, kv.SignalType.Unsigned, 0, 16, 0, 65535, out kv.SignalHnd sigHnd); kv.WriteFile(dbHnd, "./testDBC.dbc"); ```