Possible data loss during MF4 finalization (mdflib / multithreaded writer) #153
-
|
Hi, I'm currently doing my first internship, working solo on developing a CAN data collection application. I'm encountering an issue with missing data when finalizing MF4 files using mdflib. Application architectureCAN Reader Thread
DBC Decoder Thread
MF4 Writer Component (called by Decoder Thread)
File rotation
Shutdown / finalization sequenceGraceful shutdown (e.g., SIGINT)
I've added delays before stopping the writer, but it doesn’t solve the issue. Observed problemConsistently, the last ~1 % of the frames sent to the Mf4Writer are missing from the resulting MF4 file.
QuestionIs there a known buffering mechanism within mdflib (beyond standard file I/O buffering) that might require an explicit flush before calling |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
@simonhyliko The weakness of this design is that if a late sample is added to the queue ( Some comments.
|
Beta Was this translation helpful? Give feedback.
-
|
@simonhyliko I am currently developing a CAN to MQTT application that is similar to your application (ihedvall/cantomqtt). The Bus Master is a GUI application that simulates automotive buses (ihedvall/busmaster). The Bus Message Lib is a simple serialization and bus interface library. The above is little bit tricky to understand but might be considered if your application will be used by a customer. Best Regards |
Beta Was this translation helpful? Give feedback.
@simonhyliko
You are right that there is an internal queue of CAN messages.
The internal queue is thread-safe so you don't need to create an own queue.
The queue solves the problem of the pretrig time and the compression option.
The internal queue is created when calling the
InitMeasurement() function.The main issue is that the queue assumes that all messages are put onto the queue in time order.
When your application calls the
StartMeasurement(start time)and a later call withStopMeasurement(stop time),all samples between start time - pretrig time and the stop time. are stored to the file.After the start, the internal queue is periodically stored to the disc.
The weakness of this des…