pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


diffUSec rework, try #667
Posted by Anonymous on Mon 21st Oct 2019 14:44
raw | new post
view followups (newest first): diffUSec rework, try #668 by Anonymous
modification of post by Anonymous (view diff)

  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..78440b7 100644
  3. --- a/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
  4. +++ b/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
  5. @@ -32,6 +32,7 @@
  6.  #include <time.h>
  7.  #include <limits.h>
  8.  #include <stdio.h>
  9. +#include <string.h>
  10.  
  11.  /*****************************************************************************/
  12.  /*    here: Defines                                                          */
  13. @@ -54,7 +55,10 @@ static inline int diffUSec(struct timespec t1, struct timespec t2)
  14.     // calculate and return the difference of t1 and t2 in microseconds
  15.  
  16.     diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
  17. -   diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
  18. +   if (t1.tv_nsec > t2.tv_nsec)
  19. +       diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
  20. +   else
  21. +       diff += (((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000)+USEC_PER_SEC;
  22.  
  23.     return diff;
  24.  }
  25. @@ -245,6 +249,7 @@ Ecu01SoftCompCap::Ecu01SoftCompCap():
  26.  {
  27.     int prio = sched_get_priority_max(SCHED_FIFO);
  28.     struct sched_param param;
  29. +   (void)memset(&param, 0, sizeof(param));
  30.  
  31.     param.sched_priority = prio;

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