or Connect
AVS › AVS Forum › HDTV › HDTV Technical › logging signal quality with HDHomeRun
New Posts  All Forums:Forum Nav:

logging signal quality with HDHomeRun

post #1 of 2
Thread Starter 
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;
  }
post #2 of 2
Thread Starter 
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.
Edited by DAP - 9/1/13 at 9:40pm
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: HDTV Technical
AVS › AVS Forum › HDTV › HDTV Technical › logging signal quality with HDHomeRun