Skip to content

Instantly share code, notes, and snippets.

@dnas2
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnas2/23ff1aff17dada121415 to your computer and use it in GitHub Desktop.
Save dnas2/23ff1aff17dada121415 to your computer and use it in GitHub Desktop.
Read radio mic strength CSV
/*
This file takes a CSV output from rtlsdr_scanner (http://eartoearoak.com/software/rtlsdr-scanner)
and parses it to see whether three distinct radio mic channels have a carrier on them.
Call the CLI version of rtlsdr_scanner using something like:
rtlsdr_scan.py -s 863 -e 865 -f 256 -g 20 "Z:\RadioMicMonitor\scan.csv"
Created by Dom Smith as part of Red Gate Software's Down Tools Week, March 2014
*/
private Dictionary<string, bool> parseCsv()
{
var reader = new StreamReader(File.OpenRead(@"Z:\RadioMicMonitor\scan.csv"));
bool headerRow = true;
Dictionary<string, bool> micStatus = new Dictionary<string, bool> {
{"mic1",false},
{"mic2",false},
{"mic3",false}
};
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');
if (!headerRow)
{
// Cast mhz to float
float mhzFloat = float.Parse(values[1]);
float dbFloat = float.Parse(values[2]);
if (dbFloat > -30)
{
StringBuilder status = new StringBuilder();
status.Append("Strength ");
status.Append(dbFloat.ToString());
status.Append("dB on ");
status.Append(mhzFloat.ToString());
status.Append("MHz");
toolStripStatusLabel1.Text = status.ToString();
if (mhzFloat > 863.05 && mhzFloat < 863.15)
{
micStatus["mic1"] = true;
}
if (mhzFloat > 863.65 && mhzFloat < 863.75)
{
micStatus["mic2"] = true;
}
if (mhzFloat > 864.05 && mhzFloat < 864.15)
{
micStatus["mic3"] = true;
}
}
}
headerRow = false;
}
reader.Close();
return micStatus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment