Timestamp in Linux using ftime for millisecond timing

I am working on an embedded project at the moment that prints debug messages to a serial console. ?Interestingly, it seems that some of the prints are arriving out order from the actual flow of the software when they originate from the same thread.

To debug the printing problem and to add another, better layer, of debugging to the project I added a time stamp to a preprocessor definition for the existing printf() macro.

Here is the existing print macro:

#define debug_print(fmt, arg) printf (fmt, arg) To add a time stamp we need to use the timeb struct from sys/timeb.h. Since a struct is used, we need to give it

[Continue reading]