Guest User

Untitled

a guest
Apr 8th, 2015
234
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- channel_scan.sh 2015-04-06 23:52:24.395502907 -0400
  2. +++ debug.sh 2015-04-07 18:59:29.252865459 -0400
  3. @@ -52,6 +52,7 @@
  4. echo "-c // Output scan results in CSV format"
  5. echo "-l <filename> // Log the output to <filename>"
  6. echo "-b // Brief mode. No dB info or secondary channels"
  7. + echo "-D // Debug mode. To extrapolate SS values > 100%"
  8. echo "-n // Do not scan, only report devices and tuners available"
  9. echo -e "-h // This help info\n"
  10. exit
  11. @@ -80,7 +81,7 @@
  12.  
  13. CheckOpts () {
  14. local OPTIND
  15. -while getopts ":hnd:t:l:cb" OPTIONS
  16. +while getopts ":hnd:t:l:cbD" OPTIONS
  17. do
  18. case "$OPTIONS" in
  19. h)
  20. @@ -114,6 +115,9 @@
  21. b)
  22. BRIEF="y"
  23. ;;
  24. + D)
  25. + DEBUG="y"
  26. + ;;
  27. :)
  28. echo -e "\nOption -$OPTARG requires an argument."
  29. DisplayHelp
  30. @@ -187,6 +191,33 @@
  31. echo "$NumChannels channels found"
  32. }
  33.  
  34. +GetDebugData () {
  35. +# GetDebugData : Tune each channel, and grab stats using debug mode so we can extrapolate strong signals above SS = 100%, parse the output and
  36. +# plotting 'dbg = xxx' (X axis) vs SS, dBmV (Y axis) in excel within the usable 0-100 SS range yields a linear relationship
  37. +# My tuner (HDHR3-US) worked out to having a slope = 0.139874758, round to .14. and an intercept = 58.7553810994, round to 58.8
  38. +
  39. +# store the results in $ScanResults
  40. +
  41. + echo -e "\nBeginning scan on $ScanDev, tuner $ScanTuner at $(date '+%D %T')\n"
  42. + #ScanResults=$(./test.sh $HDHRConfig $ScanDev $ScanTuner)
  43. +
  44. + ScanResults=$(CHANNEL=2
  45. + while [ $CHANNEL -lt 52 ]; do
  46. + $HDHRConfig $ScanDev set /tuner$ScanTuner/channel auto:$CHANNEL
  47. + sleep 1
  48. + RESULTS=$(hdhomerun_config 103AB6AA get /tuner0/debug \
  49. + | tr -s "\n()=:" " " \
  50. + | sed 's/none/none none/g; s/\// /g' \
  51. + | grep "tun")
  52. + echo $RESULTS
  53. + let CHANNEL=$CHANNEL+1
  54. + done)
  55. +
  56. + NumChannels=$(wc -l <<< "$ScanResults")
  57. + echo "$NumChannels channels found"
  58. +
  59. +}
  60. +
  61. LogOutput () {
  62. # LogOutput : Re-parse the $ScanResults data and
  63. # append it to $DataLog
  64. @@ -232,8 +263,35 @@
  65. | sort -n
  66. }
  67.  
  68. +DebugOutput () {
  69. +# DebugOutput : Used when selecting debug mode
  70. +
  71. + echo -e "RF\tStrngth\tdBmV\tdBm\tQuality\tSNR\tSymbol\tdbg\tCalc_dBmV\tCalc_dBm"
  72. + printf '%.0s-' {1..92}; echo
  73. + awk -v OFS='\t' '{print $4,$9 \
  74. + ,($9 * 60 / 100 - 60) \
  75. + ,($9 * 60 / 100 -60 -48.75) \
  76. + ,$11,($11 / 100 * 33),$13,$15,(.14 * $15 + 58.8),"\t"(.14 * $15 + 58.8 - 48.75)}' \
  77. + <<< "$ScanResults" \
  78. + | sort -n
  79. +}
  80. +
  81. +
  82. +ScanType () {
  83. +if [ -n "$DEBUG" ]
  84. +then
  85. +echo "debug mode"
  86. +GetDebugData
  87. +else
  88. +GetScanData
  89. +fi
  90. +}
  91. +
  92. FinalOutput () {
  93. -if [ -n "$DataLog" ]
  94. +if [ -n "$DEBUG" ]
  95. +then
  96. +DebugOutput
  97. +elif [ -n "$DataLog" ]
  98. then
  99. LogOutput
  100. elif [ -n "$CSV" ]
  101. @@ -252,5 +310,6 @@
  102. CheckOpts "$@"
  103. DiscoverDevices
  104. CheckTunerLockStatus
  105. -GetScanData
  106. +#GetScanData
  107. +ScanType
  108. FinalOutput
RAW Paste Data