Skip to content

Commit

Permalink
18012020 update
Browse files Browse the repository at this point in the history
18012020 update
  • Loading branch information
GoranRadivojevic committed Jan 18, 2020
1 parent cda6def commit c7da357
Show file tree
Hide file tree
Showing 10 changed files with 880 additions and 293 deletions.
2 changes: 1 addition & 1 deletion SDRSharp.CAT/CATPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public double Frequency
set
{
long newFrequency = (long)(value * 1e6);
long newCenterFrequency = newFrequency + (_sdr.RFBandwidth / 4);
long newCenterFrequency = newFrequency + (_sdr.RFBandwidth / 8);
_sdr.Frequency = newFrequency;
_sdr.ResetFrequency(newFrequency, newCenterFrequency);
_sdr.Perform();
Expand Down
21 changes: 20 additions & 1 deletion SDRSharp.CAT/SDRSharp.CAT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\SDRsharp\sdrSharp\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -56,6 +56,25 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\..\..\Radio\SDR# x64\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="SDRSharp.Common">
<HintPath>..\..\SDRsharp\sdrSharp\SDRSharp.Common.dll</HintPath>
Expand Down
10 changes: 10 additions & 0 deletions SDRSharp.LimeSDR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|x64.ActiveCfg = Debug|x64
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|x64.Build.0 = Debug|x64
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|x86.ActiveCfg = Debug|x86
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Debug|x86.Build.0 = Debug|x86
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|Any CPU.Build.0 = Release|Any CPU
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|x64.ActiveCfg = Release|x64
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|x64.Build.0 = Release|x64
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|x86.ActiveCfg = Release|x86
{6B7747F2-331A-4865-B006-BA6419DB9E98}.Release|x86.Build.0 = Release|x86
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|x64.ActiveCfg = Debug|x64
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|x64.Build.0 = Debug|x64
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|x86.ActiveCfg = Debug|x86
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Debug|x86.Build.0 = Debug|x86
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|Any CPU.Build.0 = Release|Any CPU
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|x64.ActiveCfg = Release|x64
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|x64.Build.0 = Release|x64
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|x86.ActiveCfg = Release|Any CPU
{FEFA493A-59A2-4DCF-B491-1D498B722B65}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion SDRSharp.LimeSDR/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<configuration>
<startup>

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup>
</configuration>
179 changes: 105 additions & 74 deletions SDRSharp.LimeSDR/LimeSDRControllerDialog.Designer.cs

Large diffs are not rendered by default.

165 changes: 149 additions & 16 deletions SDRSharp.LimeSDR/LimeSDRControllerDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class LimeSDRControllerDialog : Form
private bool _initialized;
public double _sampleRate = 1.5 * 1e6;
public double _freqDiff = 0.0;
public double _GFIR_BPF_Width = 0.0;

public LimeSDRControllerDialog(LimeSDRIO owner)
{
Expand Down Expand Up @@ -58,6 +59,7 @@ public LimeSDRControllerDialog(LimeSDRIO owner)
ant_w.Checked = Utils.GetBooleanSetting("LimeSDR ANT_W");
udSpecOffset.Value = (decimal)Utils.GetDoubleSetting("LimeSDR SpecOffset", 50);
udFrequencyDiff.Value = (decimal)Utils.GetDoubleSetting("LimeSDR Frequency diff.", 0.0);
udGFIR_BPF_Width.Value = (decimal)Utils.GetDoubleSetting("LimeSDR GFIR BPF width", 0.0);
}
catch(Exception ex)
{
Expand Down Expand Up @@ -135,14 +137,48 @@ private void LimeSDRControllerDialog_FormClosing(object sender, FormClosingEvent

private void gainBar_Scroll(object sender, EventArgs e)
{
if (!Initialized)
try
{
return;
}
if (!Initialized)
{
return;
}

_owner.Gain = gainBar.Value;
gainDB.Text = gainBar.Value + " dB";
Utils.SaveSetting("LimeSDR Gain", (int)gainBar.Value);
tbLimeSDR_LNAGain.Value = Math.Max(tbLimeSDR_LNAGain.Minimum, _owner.LNAgain);
tbLimeSDR_PGAGain.Value = Math.Max(tbLimeSDR_PGAGain.Minimum, _owner.PGAgain);
tbLimeSDR_TIAGain.Value = Math.Max(tbLimeSDR_TIAGain.Minimum, _owner.TIAgain);

ushort lnaGain = 0;

if (tbLimeSDR_LNAGain.Value <= 6)
lnaGain = (ushort)tbLimeSDR_LNAGain.Value;
else
lnaGain = (ushort)(6 + (tbLimeSDR_LNAGain.Value - 6) * 3);

lblLimeSDR_LNAGain.Text = lnaGain.ToString() + "dB";

switch (tbLimeSDR_TIAGain.Value)
{
case 1:
lblLimeSDR_TIAGain.Text = "0dB";
break;

_owner.Gain = gainBar.Value;
gainDB.Text = gainBar.Value + " dB";
Utils.SaveSetting("LimeSDR Gain", (int)gainBar.Value);
case 2:
lblLimeSDR_TIAGain.Text = "3dB";
break;

case 3:
lblLimeSDR_TIAGain.Text = "12dB";
break;
}
}
catch(Exception ex)
{
Debug.Write(ex.ToString());
}
}

private void rx0_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -262,7 +298,7 @@ private void btnRadioRefresh_Click(object sender, EventArgs e)
comboRadioModel.Text = Utils.GetStringSetting("LimeSDR model", "");
}

GetLimeSDRDeviceInfo();
GetLimeSDRDeviceData();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -304,9 +340,7 @@ private void comboRadioModel_SelectedIndexChanged(object sender, EventArgs e)
_owner.RadioName = comboRadioModel.SelectedItem.ToString();
Utils.SaveSetting("LimeSDR model", comboRadioModel.Text);

txtRadioModel.Text = "";
txtFirm_version.Text = "";
txtSerialNumber.Text = "";
txtGatewareVersion.Text = "";
txtLimeSuiteVersion.Text = "";
}
Expand Down Expand Up @@ -337,11 +371,22 @@ private void tbLimeSDR_LNAGain_Scroll(object sender, EventArgs e)
{
try
{
lblLimeSDR_LNAGain.Text = tbLimeSDR_LNAGain.Value.ToString() + "dB";
ushort lnaGain = 0;

if (tbLimeSDR_LNAGain.Value <= 6)
lnaGain = (ushort)tbLimeSDR_LNAGain.Value;
else
lnaGain = (ushort)(6 + (tbLimeSDR_LNAGain.Value - 6) * 3);

lblLimeSDR_LNAGain.Text = lnaGain.ToString() + "dB";

if (_owner != null)
{
_owner.LNAgain = (ushort)tbLimeSDR_LNAGain.Value;
}

gainBar.Value = (int)(_owner.Gain * 73.0);
gainDB.Text = gainBar.Value + " dB";
}
catch (Exception ex)
{
Expand All @@ -353,11 +398,28 @@ private void tbLimeSDR_TIAGain_Scroll(object sender, EventArgs e)
{
try
{
lblLimeSDR_TIAGain.Text = tbLimeSDR_TIAGain.Value.ToString() + "dB";
switch (tbLimeSDR_TIAGain.Value)
{
case 1:
lblLimeSDR_TIAGain.Text = "0dB";
break;

case 2:
lblLimeSDR_TIAGain.Text = "3dB";
break;

case 3:
lblLimeSDR_TIAGain.Text = "12dB";
break;
}

if (_owner != null)
{
_owner.TIAgain = (ushort)tbLimeSDR_TIAGain.Value;
}

gainBar.Value = (int)(_owner.Gain * 73.0);
gainDB.Text = gainBar.Value + " dB";
}
catch (Exception ex)
{
Expand All @@ -372,8 +434,48 @@ private void tbLimeSDR_PGAGain_Scroll(object sender, EventArgs e)
lblLimeSDR_PGAGain.Text = tbLimeSDR_PGAGain.Value.ToString() + "dB";

if (_owner != null)
{
_owner.PGAgain = (ushort)tbLimeSDR_PGAGain.Value;
}

gainBar.Value = (int)(_owner.Gain * 73.0);
gainDB.Text = gainBar.Value + " dB";
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}

public unsafe void GetLimeSDRDeviceData()
{
try
{
if (_owner.LimeSDR_Device != IntPtr.Zero)
{
lms_dev_info_t info = new lms_dev_info_t();

info.deviceName = new char[32];
info.expansionName = new char[32];
info.firmwareVersion = new char[16];
info.hardwareVersion = new char[16];
info.protocolVersion = new char[16];
info.boardSerialNumber = 0;
info.gatewareVersion = new char[16];
info.gatewareTargetBoard = new char[32];
IntPtr deviceInfo;

deviceInfo = (IntPtr)NativeMethods.LMS_GetDeviceInfo(_owner.LimeSDR_Device);
byte[] buff = new byte[168];
Marshal.Copy(deviceInfo, buff, 0, 168);
ASCIIEncoding ascii = new ASCIIEncoding();
string s = ascii.GetString(buff);
string deviceName = ascii.GetString(buff, 0, 32).Trim('\0');
string expansionName = ascii.GetString(buff, 32, 32).Trim('\0');
string firmwareVersion = ascii.GetString(buff, 64, 16).Trim('\0');
string hardwareVersion = ascii.GetString(buff, 80, 16).Trim('\0');
string protocolVersion = ascii.GetString(buff, 96, 16).Trim('\0');
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -419,30 +521,61 @@ public unsafe void GetLimeSDRDeviceInfo()
serial = serial << 8;
}

string boardSerialNumber = serial.ToString("X");
string gatewareVersion = ascii.GetString(buff, 120, 16).Trim('\0');
string gatewareTargetBoard = ascii.GetString(buff, 136, 32).Trim('\0');

IntPtr libVersion;
libVersion = (IntPtr)NativeMethods.LMS_GetLibraryVersion();
string limeSuiteVersion = Marshal.PtrToStringAnsi(libVersion);

txtRadioModel.Text = deviceName;
txtFirm_version.Text = firmwareVersion;
txtSerialNumber.Text = boardSerialNumber;
txtGatewareVersion.Text = gatewareVersion;
txtLimeSuiteVersion.Text = limeSuiteVersion;
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
txtRadioModel.Text = "";
txtFirm_version.Text = "";
txtSerialNumber.Text = "";
txtGatewareVersion.Text = "";
txtLimeSuiteVersion.Text = "";
}
}

private void btnRadioInfo_Click(object sender, EventArgs e)
{
try
{
GetLimeSDRDeviceInfo();

if (_owner != null && _owner.Device != null)
{
double temperature = _owner.Device.ReadTemperature();
txtTemperature.Text = temperature.ToString("F1") + "C";
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}

private void udGFIR_BPF_Width_ValueChanged(object sender, EventArgs e)
{
try
{
_GFIR_BPF_Width = (double)udGFIR_BPF_Width.Value * 1e6;

if (_owner != null && _owner.Device != null)
{
_owner.Device.Set_GFIR_BPF_Width((double)((double)udGFIR_BPF_Width.Value * 1e6));
Utils.SaveSetting("LimeSDR GFIR BPF width", udGFIR_BPF_Width.Value.ToString());
}
}
catch (Exception ex)
{
Debug.Write(ex.ToString());
}
}
}
}
Loading

0 comments on commit c7da357

Please sign in to comment.