logging signal quality with HDHomeRun - AVS Forum | Home Theater Discussions And Reviews
Baselworld is only a few weeks away. Getting the latest news is easy, Click Here for info on how to join the Watchuseek.com newsletter list. Follow our team for updates featuring event coverage, new product unveilings, watch industry news & more!


Forum Jump: 
 
Thread Tools
post #1 of 2 Old 08-31-2013, 10:22 PM - Thread Starter
DAP
AVS Special Member
 
DAP's Avatar
 
Join Date: Mar 2001
Location: San Jose, CA
Posts: 1,246
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 8 Post(s)
Liked: 14
I hacked together a really simple tool to log signal quality from an HDHomeRun.
You will need to edit it to specify your tuner ID #s, and the channel you want to log.
I wrote it for Linux, it probably won't be too difficult to translate to windows or mac, but I have neither, so I won't be doing it.
It uses calls to the hdhomerun_config tool to talk to the tuner.
It outputs the results to stdout.
It runs until you do a CTL-C to kill it.
To plot the results, use the plotting functions in a spreadsheet. Load it as a CSV file and use spaces and "=" as delimiters.
If you want to know what the numbers mean, refer to the documentation for hdhomerun_config. (there is a man page for it.)
compile it by typing: gcc filename.c
where filename.c is the name you gave the file you saved this as.
the executable will be called "a.out"

This forum does not allow attaching C source files, so you will just have to cut & paste this code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/timeb.h>

int main (int argc, char *argv[])
  {
  FILE *fp;
  int status;
  char state[2048];
  int i;
  struct tm *timestruct;
  time_t timestamp;
  struct timeb finetime;

  fp = popen("/usr/bin/hdhomerun_config 1016A87D set /tuner0/channel 8vsb:7","r");
  if (fp == NULL)
    {
    printf("Failed to run command.\n");
    exit;
    }
  timestamp=time((time_t *)NULL);
  timestruct=localtime(&timestamp);
  printf("date: %d/%d/%d ",timestruct->tm_year,timestruct->tm_mon,timestruct->tm_mday);
  while(fgets(state, sizeof(state-1),fp) !=NULL)
    {
    printf("%s",state);
    }
  pclose(fp);

  while(1)//for(i=0;i<4096;i++)
    {
    fp = popen("/usr/bin/hdhomerun_config 1016A87D get /tuner0/status ","r");
    if (fp == NULL)
      {
      printf("Failed to run command.\n");
      exit;
      }

    timestamp=ftime(&finetime);
    timestruct=localtime(&(finetime.time));
    printf("%d:%d:%d.%03d ",timestruct->tm_hour,timestruct->tm_min,timestruct->tm_sec,finetime.millitm);
    while(fgets(state, sizeof(state-1),fp) !=NULL)
      {
      printf("%s",state);
      }
    pclose(fp);
    }
  return 0;
  }
DAP is offline  
Sponsored Links
Advertisement
 
post #2 of 2 Old 09-01-2013, 09:29 PM - Thread Starter
DAP
AVS Special Member
 
DAP's Avatar
 
Join Date: Mar 2001
Location: San Jose, CA
Posts: 1,246
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 8 Post(s)
Liked: 14
updated version. This one, if it sees 3 or more identical samples, reports just the first and last of the group. It also has a count of the number of identical samples.
I also changed the tuner I was using because MythTV interrupted a log I was attempting when it started a recording.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/timeb.h>
#include <string.h>

int main (int argc, char *argv[])
  {
  FILE *fp;
  int status;
  char state0[2048],state1[2048];
  char *state[2]={state0,state1};
  int i,index,len;
  struct tm *timestruct;
  time_t timestamp;
  struct timeb finetime,oldfinetime;

  state0[0]=0;
  state0[1]=0;
  fp = popen("/usr/bin/hdhomerun_config 1016A87D set /tuner1/channel 8vsb:7","r");
  if (fp == NULL)
    {
    printf("Failed to run command.\n");
    exit;
    }
  timestamp=time((time_t *)NULL);
  timestruct=localtime(&timestamp);
  printf("date: %d/%d/%d ",timestruct->tm_year,timestruct->tm_mon,timestruct->tm_mday);
  while(fgets(state0, sizeof(state0)-1,fp) !=NULL)
    {
    printf("%s",state0);
    }
  pclose(fp);

  i=0;
  index=0;
  while(1)//for(i=0;i<4096;i++)
    {
    fp = popen("/usr/bin/hdhomerun_config 1016A87D get /tuner1/status ","r");
    if (fp == NULL)
      {
      printf("Failed to run command.\n");
      exit;
      }

    timestamp=ftime(&finetime);
    len=0;
    while(fgets((state[index])+len, sizeof(state0)-len-1,fp) !=NULL)
      {
      len=strlen(state[index]);
      if(len>=sizeof(state0)-1)break;
      }
    pclose(fp);
    if(strcmp(state0,state1))//if strings are different
      {
      if(i>=1)
        {
        timestruct=localtime(&(oldfinetime.time));
        printf("%d:%d:%d.%03d rep= %d %s",timestruct->tm_hour,timestruct->tm_min,timestruct->tm_sec,oldfinetime.millitm,i,state[(index+1)%2]);
        }
      timestruct=localtime(&(finetime.time));
      printf("%d:%d:%d.%03d rep= %d %s",timestruct->tm_hour,timestruct->tm_min,timestruct->tm_sec,finetime.millitm,0,state[index]);
      index++;
      index%=2;
      i=0;
      }
    else
      {
      i++;
      }
    oldfinetime=finetime;
    }
  return 0;
  }

edit: fix sloppy bounds checking.
DAP is offline  
Sponsored Links
Advertisement
 
Reply HDTV Technical



Forum Jump: 

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off