pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


diffUSec rework, try #666
Posted by Anonymous on Mon 21st Oct 2019 14:09
raw | new post
view followups (newest first): diffUSec rework, try #667 by Anonymous

  1. diff --git a/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp b/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
  2. index c5c85b5..653eb95 100644
  3. --- a/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
  4. +++ b/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
  5. @@ -45,26 +45,29 @@
  6.  
  7.  // ****************************************************************************
  8.  // function: diffUSec
  9.  // ****************************************************************************
  10.  
  11.  static inline int diffUSec(struct timespec t1, struct timespec t2)
  12.  {
  13.     int diff;
  14.  
  15.     // calculate and return the difference of t1 and t2 in microseconds
  16.  
  17.     diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
  18. -   diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
  19. -
  20. +   if (t2.tv_sec > t1.tv_sec)
  21. +       diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
  22. +   else
  23. +       diff += (((int) t1.tv_nsec + (int) t2.tv_nsec) / 1000)+USEC_PER_SEC;
  24. +  
  25.     return diff;
  26.  }
  27.  
  28.  // ****************************************************************************
  29.  // ****************************************************************************
  30.  // class: gpioCallBack
  31.  // ****************************************************************************
  32.  // ****************************************************************************
  33.  
  34.  // ****************************************************************************
  35.  // constructor: gpioCallBack
  36.  // ****************************************************************************

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at