CANBus Logging and DBC Decoding #124
-
Using this library, I have created a canbus logger application. For post processing, we apply DBCs to the canbus log MF4 file in order to decode the CAN signals. I am having issues getting the time channel data in the correct format for my post-processing tools to decode the CAN data properly. If I resample my time channel using the asammdf tools, then it is decoded correctly by the asammdf dbc application tools. Once the DBC is applied, I get errors that the CAN signal Channel Group's acquisition source address must point to the same block as the master CG. The result of this is that tools such as asammdf GUI split each of the CAN signals into unique channel groups without a common master time. I have compared this to the output of processed MF4 can log files from CSS Electronic's canedge. If I use the asammdf python library tools to re-base the time channel from zero, the problem is fixed and the DBC decode tools work as expected. Am I missing something in the way I record my timestamps using this library? The can messages right now are read from a message buffer queue and then written to the MDF file using the SaveCanMessage function.
Sample Data: |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
Some further troubleshooting seems to point towards a difference between these files being in MDF 4.1 and MDF 4.2. It's possible this is an issue with the asammdf tools rather than my MDF file. When it's converted to MDF V4.1 before applying the dbc, everything is ok. |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere
When calling StartMeasurement(start time), the start time sets the HD block creation time. All timestamps in the MDF file is now relative to this absolute time. When some later calling the SaveSample(sample time + CG reference), the sample is temporary stored in an internal queue. This internal queue is periodically (10s) flushed onto the MDF file. The sample time is now converted to a relative time = sample time - start time. Creating a sorted MDF file is little bit difficult as it each CAN message is not equal to one CG sample. There exist so-called multiplexed signals meaning that a CAM message may have a new signal value. To solve this, the converter normally use the last reported multiplexed signal value. A worse problem is signals (typical Diagnostic signals) that is larger than 8-bytes. To make it worse, it depends on the transport protocol on top of the CAN bus. If you are lucky, this is defined in the DBC file but you are normally not lucky. There is something wrong with the sorted file. Its output configuration looks like it uses a remote (common) time master. This is a very complicated way of handling the time channel. I need to investigate further why the ASAMMDF library behave like this. There is a weakness in the mdflib CAN configuration. It doesn't add the SI block. I will fix this issue later on (issue #120) but for the time being, you may add this block manually, after the CreateCANConfiguration() call. I will try to reproduce the problem. I might need the DBC and the MDF bus logger file. |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere
My guess is that [2] used the mdflib bus writer. The "only" difference between [2] and [4], is the MDF version number. I think that the asammdf is using the version number in the ID block and do some "new" type of sorting conversion. I don't have the DBC file, so check if you can "tell" the asammdf, to not do the 4.2 conversion. I will try to see if it's possible to set the mdflib version to 4.11 instead of 4.2. |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere auto writer = MdfFactory::CreateMdfWriter(MdfWriterType::MdfBusLogger);
writer->Init(mdf_file.string());
if (auto* md4_file = writer->GetFile();
md4_file != nullptr ) {
md4_file->MinorVersion(11);
} |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere Hint 2: |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere
Just to be evil, the CG naming is different for each configuration. Note that issue #120 includes [2] and [3]. The last configuration is of interest as it is now possible to add DBC signal values to the CG block. You need something like the dbclib so you can update both the CAN message bytes as well as the signal values, on the fly. Note that you need one DBC file per CAN channel, so it's a little bit of a setup issue. |
Beta Was this translation helpful? Give feedback.
-
@lawsonampere A typical design is to divide the measurement data system into 2 sub-system. The first system shall long-time store and validate the measurement data files (CAN log files as above). The second sub-system create Parquet files and stores them in some optimized way for data processing. The second sub-system is a so-called Data Lake system. Often a small index database is added for keeping track of the MDF/DBC files. The Data Lake system normally only stores a sub-set of the last measurements i.e not for long-time storage. |
Beta Was this translation helpful? Give feedback.
@lawsonampere
Analyzing the files.
My guess is that [2] used the mdflib bus writer. The "only" difference between [2] and [4], is the MDF version number. …