mirror of
https://github.com/prirun/p50em.git
synced 2026-01-23 18:47:04 +00:00
Nanosecond log resolution for SMLC debug log
Using clock_gettime(), fetch the realtime clock, which has as much as nanosecond resolution. (In reality, it will likely ben more like microseconds, though it returns the value in nanoseconds.) Use the nanosecond value in SMLC log entries. On modern systems and over ethernet links, second resolution is probably fairly coarse for trying to debug RJE problems.
This commit is contained in:
parent
edf7129651
commit
6bf6e2ea48
@ -49,6 +49,7 @@
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
|
||||
#define SMLC_DEVICEID 0050 /* HSSMLC/MDLC is '50, SMLC is '56 */
|
||||
|
||||
@ -126,7 +127,7 @@ static void smlclogflush(void);
|
||||
static FILE *smlclog = NULL;
|
||||
static char smlclogbuf[LogLineLength + 1];
|
||||
static int smlclogbytescol = 0;
|
||||
static char smlctimestamp[10];
|
||||
static char smlctimestamp[20];
|
||||
#endif
|
||||
|
||||
/* connection states */
|
||||
@ -285,12 +286,14 @@ int devsmlc (int class, int func, int device) {
|
||||
fd_set writefds;
|
||||
#if DEBUG
|
||||
struct tm *tp;
|
||||
struct timespec sts;
|
||||
#endif
|
||||
|
||||
currenttime = time(0);
|
||||
#if DEBUG
|
||||
tp = localtime(¤ttime);
|
||||
sprintf(smlctimestamp, "%02d:%02d:%02d", tp->tm_hour, tp->tm_min, tp->tm_sec);
|
||||
clock_gettime(CLOCK_REALTIME, &sts);
|
||||
sprintf(smlctimestamp, "%02d:%02d:%02d.%09d", tp->tm_hour, tp->tm_min, tp->tm_sec, sts.tv_nsec);
|
||||
#endif
|
||||
|
||||
switch (device) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user