[linux-dvb] [PATCH] dvb-apps/util/szap/femon.c adding date/time in front of output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm planning on taking the data that femon puts out, and pulling it
into a graph or database. In order to do that, I needed a date/time
stamp. Here's my patch to femon.c to make this happen:


Index: femon.c
===================================================================
RCS file: /cvs/linuxtv/dvb-apps/util/szap/femon.c,v
retrieving revision 1.1
diff -u -r1.1 femon.c
--- femon.c     17 Jan 2004 16:59:46 -0000      1.1
+++ femon.c     24 Mar 2005 22:16:36 -0000
@@ -66,6 +66,8 @@
    fe_status_t status;
    uint16_t snr, signal;
    uint32_t ber, uncorrected_blocks;
+        struct tm tm;
+        char buf[255];
 
    do {
       ioctl(fe_fd, FE_READ_STATUS, &status);
@@ -73,9 +75,14 @@
       ioctl(fe_fd, FE_READ_SNR, &snr);
       ioctl(fe_fd, FE_READ_BER, &ber);
       ioctl(fe_fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks);
+
+       time_t now = time(0);
+       char * tx = ctime(&now);
+        strptime(tx, "%a %b %d %H:%M:%S %Y", &tm);
+        strftime(buf, sizeof(buf), "%b %d %H:%M:%S", &tm);
 
-      printf ("status %02x | signal %04x | snr %04x | ber %08x | unc %08x | ",
-             status, signal, snr, ber, uncorrected_blocks);
+      printf ("%s | status %02x | signal %04x | snr %04x | ber %08x |
unc %08x | ",
+             buf, status, signal, snr, ber, uncorrected_blocks);
 
       if (status & FE_HAS_LOCK)
         printf("FE_HAS_LOCK");


Right now I have this running in the background, dumping to a log
file. Then I can go back and look in the log file when I have a
problem.

As always, works for me....



[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux