From c7da357142667936c484df876f1ca42c2201b9e2 Mon Sep 17 00:00:00 2001 From: Goran Radivojevic YT7PWR Date: Sat, 18 Jan 2020 14:00:56 +0100 Subject: [PATCH] 18012020 update 18012020 update --- SDRSharp.CAT/CATPlugin.cs | 2 +- SDRSharp.CAT/SDRSharp.CAT.csproj | 21 +- SDRSharp.LimeSDR.sln | 10 + SDRSharp.LimeSDR/App.config | 2 +- .../LimeSDRControllerDialog.Designer.cs | 179 ++++--- SDRSharp.LimeSDR/LimeSDRControllerDialog.cs | 165 ++++++- SDRSharp.LimeSDR/LimeSDRDevice.cs | 271 ++++++++--- SDRSharp.LimeSDR/LimeSDRIO.cs | 48 +- SDRSharp.LimeSDR/NativeMethods.cs | 452 +++++++++++++----- SDRSharp.LimeSDR/SDRSharp.LimeSDR.csproj | 23 +- 10 files changed, 880 insertions(+), 293 deletions(-) diff --git a/SDRSharp.CAT/CATPlugin.cs b/SDRSharp.CAT/CATPlugin.cs index 6c8f0ab..dc7927c 100644 --- a/SDRSharp.CAT/CATPlugin.cs +++ b/SDRSharp.CAT/CATPlugin.cs @@ -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(); diff --git a/SDRSharp.CAT/SDRSharp.CAT.csproj b/SDRSharp.CAT/SDRSharp.CAT.csproj index 8f061da..73354ae 100644 --- a/SDRSharp.CAT/SDRSharp.CAT.csproj +++ b/SDRSharp.CAT/SDRSharp.CAT.csproj @@ -29,7 +29,7 @@ AnyCPU pdbonly true - bin\Release\ + ..\..\SDRsharp\sdrSharp\ TRACE prompt 4 @@ -56,6 +56,25 @@ prompt MinimumRecommendedRules.ruleset + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + true + + + ..\..\..\Radio\SDR# x64\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + ..\..\SDRsharp\sdrSharp\SDRSharp.Common.dll diff --git a/SDRSharp.LimeSDR.sln b/SDRSharp.LimeSDR.sln index 96399f0..40e7d94 100644 --- a/SDRSharp.LimeSDR.sln +++ b/SDRSharp.LimeSDR.sln @@ -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 diff --git a/SDRSharp.LimeSDR/App.config b/SDRSharp.LimeSDR/App.config index 156c225..e8e81a2 100644 --- a/SDRSharp.LimeSDR/App.config +++ b/SDRSharp.LimeSDR/App.config @@ -2,5 +2,5 @@ - + diff --git a/SDRSharp.LimeSDR/LimeSDRControllerDialog.Designer.cs b/SDRSharp.LimeSDR/LimeSDRControllerDialog.Designer.cs index a3d1359..291b87e 100644 --- a/SDRSharp.LimeSDR/LimeSDRControllerDialog.Designer.cs +++ b/SDRSharp.LimeSDR/LimeSDRControllerDialog.Designer.cs @@ -46,6 +46,8 @@ private void InitializeComponent() this.udSpecOffset = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.label14 = new System.Windows.Forms.Label(); + this.udGFIR_BPF_Width = new System.Windows.Forms.NumericUpDown(); this.lblLimeSDR_LNAGain = new System.Windows.Forms.Label(); this.lblLimeSDR_TIAGain = new System.Windows.Forms.Label(); this.lblLimeSDR_PGAGain = new System.Windows.Forms.Label(); @@ -58,14 +60,13 @@ private void InitializeComponent() this.label5 = new System.Windows.Forms.Label(); this.udFrequencyDiff = new System.Windows.Forms.NumericUpDown(); this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.txtSerialNumber = new System.Windows.Forms.TextBox(); + this.txtTemperature = new System.Windows.Forms.TextBox(); this.label17 = new System.Windows.Forms.Label(); + this.btnRadioInfo = new System.Windows.Forms.Button(); this.txtGatewareVersion = new System.Windows.Forms.TextBox(); this.label16 = new System.Windows.Forms.Label(); this.txtFirm_version = new System.Windows.Forms.TextBox(); this.label15 = new System.Windows.Forms.Label(); - this.txtRadioModel = new System.Windows.Forms.TextBox(); - this.label14 = new System.Windows.Forms.Label(); this.txtLimeSuiteVersion = new System.Windows.Forms.TextBox(); this.label10 = new System.Windows.Forms.Label(); this.txtRadioSerialNo = new System.Windows.Forms.TextBox(); @@ -82,6 +83,7 @@ private void InitializeComponent() this.grpAntenna.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.udSpecOffset)).BeginInit(); this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.udGFIR_BPF_Width)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_PGAGain)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_TIAGain)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_LNAGain)).BeginInit(); @@ -92,7 +94,7 @@ private void InitializeComponent() // close // this.close.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.close.Location = new System.Drawing.Point(221, 465); + this.close.Location = new System.Drawing.Point(221, 493); this.close.Name = "close"; this.close.Size = new System.Drawing.Size(75, 25); this.close.TabIndex = 0; @@ -123,11 +125,12 @@ private void InitializeComponent() // this.gainBar.AutoSize = false; this.gainBar.Location = new System.Drawing.Point(22, 80); - this.gainBar.Maximum = 70; + this.gainBar.Maximum = 73; this.gainBar.Name = "gainBar"; this.gainBar.Size = new System.Drawing.Size(199, 18); this.gainBar.TabIndex = 3; this.gainBar.TickStyle = System.Windows.Forms.TickStyle.None; + this.gainBar.Value = 40; this.gainBar.Scroll += new System.EventHandler(this.gainBar_Scroll); // // label2 @@ -142,11 +145,11 @@ private void InitializeComponent() // gainDB // this.gainDB.AutoSize = true; - this.gainDB.Location = new System.Drawing.Point(183, 63); + this.gainDB.Location = new System.Drawing.Point(184, 64); this.gainDB.Name = "gainDB"; - this.gainDB.Size = new System.Drawing.Size(19, 13); + this.gainDB.Size = new System.Drawing.Size(31, 13); this.gainDB.TabIndex = 5; - this.gainDB.Text = "db"; + this.gainDB.Text = "40db"; // // rx0 // @@ -260,7 +263,7 @@ private void InitializeComponent() // this.udSpecOffset.DecimalPlaces = 1; this.udSpecOffset.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.udSpecOffset.Location = new System.Drawing.Point(160, 359); + this.udSpecOffset.Location = new System.Drawing.Point(160, 361); this.udSpecOffset.Maximum = new decimal(new int[] { 1000, 0, @@ -285,7 +288,7 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(28, 363); + this.label4.Location = new System.Drawing.Point(28, 365); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(81, 13); this.label4.TabIndex = 18; @@ -293,6 +296,8 @@ private void InitializeComponent() // // groupBox3 // + this.groupBox3.Controls.Add(this.label14); + this.groupBox3.Controls.Add(this.udGFIR_BPF_Width); this.groupBox3.Controls.Add(this.lblLimeSDR_LNAGain); this.groupBox3.Controls.Add(this.lblLimeSDR_TIAGain); this.groupBox3.Controls.Add(this.lblLimeSDR_PGAGain); @@ -317,11 +322,46 @@ private void InitializeComponent() this.groupBox3.Controls.Add(this.gainDB); this.groupBox3.Location = new System.Drawing.Point(257, 12); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(242, 443); + this.groupBox3.Size = new System.Drawing.Size(242, 466); this.groupBox3.TabIndex = 19; this.groupBox3.TabStop = false; this.groupBox3.Text = "Settings"; // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(28, 429); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(114, 13); + this.label14.TabIndex = 31; + this.label14.Text = "GFIR BPF width (MHz)"; + // + // udGFIR_BPF_Width + // + this.udGFIR_BPF_Width.DecimalPlaces = 1; + this.udGFIR_BPF_Width.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.udGFIR_BPF_Width.Increment = new decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.udGFIR_BPF_Width.Location = new System.Drawing.Point(153, 425); + this.udGFIR_BPF_Width.Maximum = new decimal(new int[] { + 25, + 0, + 0, + 0}); + this.udGFIR_BPF_Width.Name = "udGFIR_BPF_Width"; + this.udGFIR_BPF_Width.Size = new System.Drawing.Size(62, 22); + this.udGFIR_BPF_Width.TabIndex = 30; + this.udGFIR_BPF_Width.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.udGFIR_BPF_Width.Value = new decimal(new int[] { + 15, + 0, + 0, + 65536}); + this.udGFIR_BPF_Width.ValueChanged += new System.EventHandler(this.udGFIR_BPF_Width_ValueChanged); + // // lblLimeSDR_LNAGain // this.lblLimeSDR_LNAGain.AutoSize = true; @@ -329,12 +369,12 @@ private void InitializeComponent() this.lblLimeSDR_LNAGain.Name = "lblLimeSDR_LNAGain"; this.lblLimeSDR_LNAGain.Size = new System.Drawing.Size(32, 13); this.lblLimeSDR_LNAGain.TabIndex = 29; - this.lblLimeSDR_LNAGain.Text = "21dB"; + this.lblLimeSDR_LNAGain.Text = "15dB"; // // lblLimeSDR_TIAGain // this.lblLimeSDR_TIAGain.AutoSize = true; - this.lblLimeSDR_TIAGain.Location = new System.Drawing.Point(186, 142); + this.lblLimeSDR_TIAGain.Location = new System.Drawing.Point(189, 144); this.lblLimeSDR_TIAGain.Name = "lblLimeSDR_TIAGain"; this.lblLimeSDR_TIAGain.Size = new System.Drawing.Size(26, 13); this.lblLimeSDR_TIAGain.TabIndex = 28; @@ -354,8 +394,7 @@ private void InitializeComponent() this.tbLimeSDR_PGAGain.AutoSize = false; this.tbLimeSDR_PGAGain.LargeChange = 3; this.tbLimeSDR_PGAGain.Location = new System.Drawing.Point(22, 197); - this.tbLimeSDR_PGAGain.Maximum = 37; - this.tbLimeSDR_PGAGain.Minimum = 1; + this.tbLimeSDR_PGAGain.Maximum = 31; this.tbLimeSDR_PGAGain.Name = "tbLimeSDR_PGAGain"; this.tbLimeSDR_PGAGain.Size = new System.Drawing.Size(199, 18); this.tbLimeSDR_PGAGain.TabIndex = 25; @@ -375,16 +414,16 @@ private void InitializeComponent() // tbLimeSDR_TIAGain // this.tbLimeSDR_TIAGain.AutoSize = false; - this.tbLimeSDR_TIAGain.LargeChange = 3; + this.tbLimeSDR_TIAGain.LargeChange = 1; this.tbLimeSDR_TIAGain.Location = new System.Drawing.Point(22, 158); - this.tbLimeSDR_TIAGain.Maximum = 12; - this.tbLimeSDR_TIAGain.Minimum = 3; + this.tbLimeSDR_TIAGain.Maximum = 3; + this.tbLimeSDR_TIAGain.Minimum = 1; this.tbLimeSDR_TIAGain.Name = "tbLimeSDR_TIAGain"; this.tbLimeSDR_TIAGain.Size = new System.Drawing.Size(199, 18); this.tbLimeSDR_TIAGain.SmallChange = 3; this.tbLimeSDR_TIAGain.TabIndex = 23; this.tbLimeSDR_TIAGain.TickStyle = System.Windows.Forms.TickStyle.None; - this.tbLimeSDR_TIAGain.Value = 6; + this.tbLimeSDR_TIAGain.Value = 2; this.tbLimeSDR_TIAGain.Scroll += new System.EventHandler(this.tbLimeSDR_TIAGain_Scroll); // // label7 @@ -401,13 +440,12 @@ private void InitializeComponent() this.tbLimeSDR_LNAGain.AutoSize = false; this.tbLimeSDR_LNAGain.LargeChange = 3; this.tbLimeSDR_LNAGain.Location = new System.Drawing.Point(22, 119); - this.tbLimeSDR_LNAGain.Maximum = 27; - this.tbLimeSDR_LNAGain.Minimum = 1; + this.tbLimeSDR_LNAGain.Maximum = 15; this.tbLimeSDR_LNAGain.Name = "tbLimeSDR_LNAGain"; this.tbLimeSDR_LNAGain.Size = new System.Drawing.Size(199, 18); this.tbLimeSDR_LNAGain.TabIndex = 21; this.tbLimeSDR_LNAGain.TickStyle = System.Windows.Forms.TickStyle.None; - this.tbLimeSDR_LNAGain.Value = 21; + this.tbLimeSDR_LNAGain.Value = 15; this.tbLimeSDR_LNAGain.Scroll += new System.EventHandler(this.tbLimeSDR_LNAGain_Scroll); // // label6 @@ -422,7 +460,7 @@ private void InitializeComponent() // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(28, 392); + this.label5.Location = new System.Drawing.Point(28, 397); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(106, 13); this.label5.TabIndex = 20; @@ -437,7 +475,7 @@ private void InitializeComponent() 0, 0, 131072}); - this.udFrequencyDiff.Location = new System.Drawing.Point(143, 388); + this.udFrequencyDiff.Location = new System.Drawing.Point(143, 392); this.udFrequencyDiff.Minimum = new decimal(new int[] { 100, 0, @@ -451,14 +489,13 @@ private void InitializeComponent() // // groupBox4 // - this.groupBox4.Controls.Add(this.txtSerialNumber); + this.groupBox4.Controls.Add(this.txtTemperature); this.groupBox4.Controls.Add(this.label17); + this.groupBox4.Controls.Add(this.btnRadioInfo); this.groupBox4.Controls.Add(this.txtGatewareVersion); this.groupBox4.Controls.Add(this.label16); this.groupBox4.Controls.Add(this.txtFirm_version); this.groupBox4.Controls.Add(this.label15); - this.groupBox4.Controls.Add(this.txtRadioModel); - this.groupBox4.Controls.Add(this.label14); this.groupBox4.Controls.Add(this.txtLimeSuiteVersion); this.groupBox4.Controls.Add(this.label10); this.groupBox4.Controls.Add(this.txtRadioSerialNo); @@ -472,34 +509,45 @@ private void InitializeComponent() this.groupBox4.Controls.Add(this.label9); this.groupBox4.Location = new System.Drawing.Point(6, 14); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(242, 441); + this.groupBox4.Size = new System.Drawing.Size(242, 464); this.groupBox4.TabIndex = 20; this.groupBox4.TabStop = false; this.groupBox4.Text = "Device Info"; // - // txtSerialNumber + // txtTemperature // - this.txtSerialNumber.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtSerialNumber.Location = new System.Drawing.Point(17, 363); - this.txtSerialNumber.Name = "txtSerialNumber"; - this.txtSerialNumber.ReadOnly = true; - this.txtSerialNumber.Size = new System.Drawing.Size(208, 22); - this.txtSerialNumber.TabIndex = 44; - this.txtSerialNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.txtTemperature.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtTemperature.Location = new System.Drawing.Point(17, 389); + this.txtTemperature.Name = "txtTemperature"; + this.txtTemperature.ReadOnly = true; + this.txtTemperature.Size = new System.Drawing.Size(208, 22); + this.txtTemperature.TabIndex = 45; + this.txtTemperature.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // label17 // this.label17.AutoSize = true; - this.label17.Location = new System.Drawing.Point(86, 347); + this.label17.Location = new System.Drawing.Point(93, 373); this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(71, 13); - this.label17.TabIndex = 43; - this.label17.Text = "Serial number"; + this.label17.Size = new System.Drawing.Size(67, 13); + this.label17.TabIndex = 44; + this.label17.Text = "Temperature"; + // + // btnRadioInfo + // + this.btnRadioInfo.Enabled = false; + this.btnRadioInfo.Location = new System.Drawing.Point(81, 425); + this.btnRadioInfo.Name = "btnRadioInfo"; + this.btnRadioInfo.Size = new System.Drawing.Size(75, 23); + this.btnRadioInfo.TabIndex = 43; + this.btnRadioInfo.Text = "Info"; + this.btnRadioInfo.UseVisualStyleBackColor = true; + this.btnRadioInfo.Click += new System.EventHandler(this.btnRadioInfo_Click); // // txtGatewareVersion // this.txtGatewareVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtGatewareVersion.Location = new System.Drawing.Point(17, 322); + this.txtGatewareVersion.Location = new System.Drawing.Point(17, 345); this.txtGatewareVersion.Name = "txtGatewareVersion"; this.txtGatewareVersion.ReadOnly = true; this.txtGatewareVersion.Size = new System.Drawing.Size(208, 22); @@ -509,7 +557,7 @@ private void InitializeComponent() // label16 // this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(93, 306); + this.label16.Location = new System.Drawing.Point(93, 329); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(56, 13); this.label16.TabIndex = 41; @@ -518,7 +566,7 @@ private void InitializeComponent() // txtFirm_version // this.txtFirm_version.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtFirm_version.Location = new System.Drawing.Point(17, 281); + this.txtFirm_version.Location = new System.Drawing.Point(17, 304); this.txtFirm_version.Name = "txtFirm_version"; this.txtFirm_version.ReadOnly = true; this.txtFirm_version.Size = new System.Drawing.Size(208, 22); @@ -528,35 +576,16 @@ private void InitializeComponent() // label15 // this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(78, 265); + this.label15.Location = new System.Drawing.Point(78, 288); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(86, 13); this.label15.TabIndex = 39; this.label15.Text = "Firmware version"; // - // txtRadioModel - // - this.txtRadioModel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtRadioModel.Location = new System.Drawing.Point(17, 199); - this.txtRadioModel.Name = "txtRadioModel"; - this.txtRadioModel.ReadOnly = true; - this.txtRadioModel.Size = new System.Drawing.Size(208, 22); - this.txtRadioModel.TabIndex = 38; - this.txtRadioModel.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // label14 - // - this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(88, 183); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(66, 13); - this.label14.TabIndex = 37; - this.label14.Text = "Radio model"; - // // txtLimeSuiteVersion // this.txtLimeSuiteVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtLimeSuiteVersion.Location = new System.Drawing.Point(17, 240); + this.txtLimeSuiteVersion.Location = new System.Drawing.Point(17, 263); this.txtLimeSuiteVersion.Name = "txtLimeSuiteVersion"; this.txtLimeSuiteVersion.ReadOnly = true; this.txtLimeSuiteVersion.Size = new System.Drawing.Size(208, 22); @@ -566,7 +595,7 @@ private void InitializeComponent() // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(92, 224); + this.label10.Location = new System.Drawing.Point(92, 247); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(58, 13); this.label10.TabIndex = 35; @@ -615,11 +644,11 @@ private void InitializeComponent() // // btnRadioRefresh // - this.btnRadioRefresh.Location = new System.Drawing.Point(81, 404); + this.btnRadioRefresh.Location = new System.Drawing.Point(81, 193); this.btnRadioRefresh.Name = "btnRadioRefresh"; this.btnRadioRefresh.Size = new System.Drawing.Size(75, 23); this.btnRadioRefresh.TabIndex = 30; - this.btnRadioRefresh.Text = "Refresh"; + this.btnRadioRefresh.Text = "Reload"; this.btnRadioRefresh.UseVisualStyleBackColor = true; this.btnRadioRefresh.Click += new System.EventHandler(this.btnRadioRefresh_Click); // @@ -664,7 +693,7 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.close; - this.ClientSize = new System.Drawing.Size(516, 498); + this.ClientSize = new System.Drawing.Size(516, 528); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.close); @@ -674,7 +703,7 @@ private void InitializeComponent() this.Name = "LimeSDRControllerDialog"; this.ShowIcon = false; this.ShowInTaskbar = false; - this.Text = "LimeSDR Controller YT7PWR v0.2"; + this.Text = "LimeSDR Controller YT7PWR v0.4 18012020"; this.TopMost = true; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.LimeSDRControllerDialog_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.gainBar)).EndInit(); @@ -683,6 +712,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.udSpecOffset)).EndInit(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.udGFIR_BPF_Width)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_PGAGain)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_TIAGain)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.tbLimeSDR_LNAGain)).EndInit(); @@ -717,7 +747,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox txtModule; private System.Windows.Forms.TextBox txtRadioName; private System.Windows.Forms.ComboBox comboRadioModel; - private System.Windows.Forms.Button btnRadioRefresh; private System.Windows.Forms.Label label13; private System.Windows.Forms.Label label12; private System.Windows.Forms.Label label11; @@ -735,14 +764,16 @@ private void InitializeComponent() private System.Windows.Forms.NumericUpDown udFrequencyDiff; private System.Windows.Forms.TextBox txtLimeSuiteVersion; private System.Windows.Forms.Label label10; - private System.Windows.Forms.TextBox txtRadioModel; - private System.Windows.Forms.Label label14; private System.Windows.Forms.TextBox txtGatewareVersion; private System.Windows.Forms.Label label16; private System.Windows.Forms.TextBox txtFirm_version; private System.Windows.Forms.Label label15; - private System.Windows.Forms.TextBox txtSerialNumber; - private System.Windows.Forms.Label label17; public System.Windows.Forms.GroupBox grpChannel; + public System.Windows.Forms.Button btnRadioInfo; + public System.Windows.Forms.Button btnRadioRefresh; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.NumericUpDown udGFIR_BPF_Width; + private System.Windows.Forms.TextBox txtTemperature; + private System.Windows.Forms.Label label17; } } \ No newline at end of file diff --git a/SDRSharp.LimeSDR/LimeSDRControllerDialog.cs b/SDRSharp.LimeSDR/LimeSDRControllerDialog.cs index b273928..7eaf794 100644 --- a/SDRSharp.LimeSDR/LimeSDRControllerDialog.cs +++ b/SDRSharp.LimeSDR/LimeSDRControllerDialog.cs @@ -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) { @@ -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) { @@ -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) @@ -262,7 +298,7 @@ private void btnRadioRefresh_Click(object sender, EventArgs e) comboRadioModel.Text = Utils.GetStringSetting("LimeSDR model", ""); } - GetLimeSDRDeviceInfo(); + GetLimeSDRDeviceData(); } catch (Exception ex) { @@ -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 = ""; } @@ -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) { @@ -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) { @@ -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) { @@ -419,7 +521,6 @@ 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'); @@ -427,9 +528,7 @@ public unsafe void GetLimeSDRDeviceInfo() 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; } @@ -437,12 +536,46 @@ public unsafe void GetLimeSDRDeviceInfo() 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()); + } + } } } diff --git a/SDRSharp.LimeSDR/LimeSDRDevice.cs b/SDRSharp.LimeSDR/LimeSDRDevice.cs index 3e9f287..8fa1bc4 100644 --- a/SDRSharp.LimeSDR/LimeSDRDevice.cs +++ b/SDRSharp.LimeSDR/LimeSDRDevice.cs @@ -41,8 +41,7 @@ public class LimeSDRDevice private double _sampleRate = DefaultSamplerate; private double _centerFrequency = DefaultFrequency; - private double _old_centerFrequency = DefaultFrequency; - private uint _gain = 40; + private double _gain = 40; public const bool LMS_CH_TX = true; public const bool LMS_CH_RX = false; @@ -61,6 +60,8 @@ public class LimeSDRDevice LMS7Parameter TIA_gain = new LMS7Parameter(); LMS7Parameter LNA_gain = new LMS7Parameter(); + public double GFIR_BPF_Width = 0.0; + #endregion #region Properties @@ -84,8 +85,28 @@ public double FreqDiff } } - public ushort LNAgain + unsafe public ushort LNAgain { + get + { + ushort[] buffer = new ushort[10]; + + if (_device != IntPtr.Zero) + { + fixed (ushort* value = &buffer[0]) + { + if (NativeMethods.LMS_ReadParam(_device, LNA_gain, &value[0]) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + } + } + + _lnaGain = buffer[0]; + + return _lnaGain; + } + set { _lnaGain = value; @@ -100,8 +121,28 @@ public ushort LNAgain } } - public ushort TIAgain + unsafe public ushort TIAgain { + get + { + ushort[] buffer = new ushort[10]; + + if (_device != IntPtr.Zero) + { + fixed (ushort* value = &buffer[0]) + { + if (NativeMethods.LMS_ReadParam(_device, TIA_gain, &value[0]) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + } + } + + _tiaGain = buffer[0]; + + return _tiaGain; + } + set { _tiaGain = value; @@ -116,8 +157,28 @@ public ushort TIAgain } } - public ushort PGAgain + unsafe public ushort PGAgain { + get + { + ushort[] buffer = new ushort[10]; + + if (_device != IntPtr.Zero) + { + fixed (ushort* value = &buffer[0]) + { + if (NativeMethods.LMS_ReadParam(_device, PGA_gain, &value[0]) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + } + } + + _pgaGain = buffer[0]; + + return _pgaGain; + } + set { _pgaGain = value; @@ -274,12 +335,14 @@ public unsafe void Start(uint ch, double lpbw, double gain, uint ant, double sr, if (NativeMethods.LMS_EnableChannel(_device, LMS_CH_RX, _channel, true) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } if (NativeMethods.LMS_SetAntenna(_device, LMS_CH_RX, _channel, _ant) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } this.SampleRate = _sampleRate; @@ -288,7 +351,8 @@ public unsafe void Start(uint ch, double lpbw, double gain, uint ant, double sr, { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 32) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else @@ -297,53 +361,66 @@ public unsafe void Start(uint ch, double lpbw, double gain, uint ant, double sr, { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 0) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else if (SampleRate > 16000000) { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 4) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else if (SampleRate > 8000000) { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 8) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else if (SampleRate > 4000000) { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, (double)(SampleRate), 16) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else if (SampleRate > 2000000) { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 32) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } else { if (NativeMethods.LMS_SetSampleRateDir(_device, LMS_CH_RX, SampleRate, 32) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } } - if (NativeMethods.LMS_SetGaindB(_device, LMS_CH_RX, _channel, _gain) != 0) + if (NativeMethods.LMS_SetNormalizedGain(_device, LMS_CH_RX, _channel, _gain / 73.0) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } LPBW = _lpbw; + if (NativeMethods.LMS_SetGFIRLPF(_device, LMS_CH_RX, _channel, true, GFIR_BPF_Width) != 0) + { + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + lms_stream_t streamId = new lms_stream_t(); streamId.handle = 0; streamId.channel = _channel; //channel number @@ -357,12 +434,14 @@ public unsafe void Start(uint ch, double lpbw, double gain, uint ant, double sr, if (NativeMethods.LMS_SetupStream(_device, _stream) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } if (NativeMethods.LMS_StartStream(_stream) != 0) { - throw new ApplicationException(NativeMethods.limesdr_strerror()); + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } _isStreaming = true; @@ -386,6 +465,7 @@ public unsafe long Frequency throw new ApplicationException(NativeMethods.limesdr_strerror()); } } + return (long)_centerFrequency; } set @@ -396,80 +476,61 @@ public unsafe long Frequency { if (_isStreaming) { - if (_centerFrequency < 30 * 1e6 && _old_centerFrequency >= 30 * 1e6) + if (value >= 30 * 1e6) { - _old_centerFrequency = _centerFrequency; - _isStreaming = false; - Thread.Sleep(1000); - _parrent.ReStart(); - } - else if (_centerFrequency > 30 * 1e6 && _old_centerFrequency <= 30 * 1e6) - { - _old_centerFrequency = _centerFrequency; - _isStreaming = false; - Thread.Sleep(1000); - _parrent.ReStart(); + if (NativeMethods.LMS_SetNCOIndex(_device, LMS_CH_RX, _channel, 15, true) != 0) // 0.0 NCO + { + _isStreaming = false; + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + + if (NativeMethods.LMS_SetLOFrequency(_device, LMS_CH_RX, _channel, _centerFrequency + _freqDiff) != 0) + { + _isStreaming = false; + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); + } } else { - _old_centerFrequency = _centerFrequency; + if (NativeMethods.LMS_SetLOFrequency(_device, LMS_CH_RX, _channel, 30.0 * 1e6) != 0) + { + _isStreaming = false; + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + + double[] losc_freq = new double[16]; + double[] pho = new double[1]; - if (_device != IntPtr.Zero) + fixed (double* freq = &losc_freq[0]) + fixed (double* pho_ptr = &pho[0]) { - if (value >= 30 * 1e6) + losc_freq[0] = (30.0 * 1e6) - _centerFrequency; + losc_freq[15] = 0.0; + + if (NativeMethods.LMS_SetNCOFrequency(_device, LMS_CH_RX, _channel, freq, 0.0) != 0) { - if (NativeMethods.LMS_SetNCOIndex(_device, LMS_CH_RX, _channel, 15, true) != 0) // 0.0 NCO - { - _isStreaming = false; - throw new ApplicationException(NativeMethods.limesdr_strerror()); - } - - if (NativeMethods.LMS_SetLOFrequency(_device, LMS_CH_RX, _channel, _centerFrequency + _freqDiff) != 0) - { - throw new ApplicationException(NativeMethods.limesdr_strerror()); - } + _isStreaming = false; + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } - else + + if (NativeMethods.LMS_SetNCOIndex(_device, LMS_CH_RX, _channel, 0, false) != 0) { - if (NativeMethods.LMS_SetLOFrequency(_device, LMS_CH_RX, _channel, 30.0 * 1e6) != 0) - { - _isStreaming = false; - throw new ApplicationException(NativeMethods.limesdr_strerror()); - } - - double[] losc_freq = new double[16]; - double[] pho = new double[1]; - - fixed (double* freq = &losc_freq[0]) - fixed (double* pho_ptr = &pho[0]) - { - losc_freq[0] = (30.0 * 1e6) - _centerFrequency; - losc_freq[15] = 0.0; - - if (NativeMethods.LMS_SetNCOFrequency(_device, LMS_CH_RX, _channel, freq, 0.0) != 0) - { - _isStreaming = false; - throw new ApplicationException(NativeMethods.limesdr_strerror()); - } - - if (NativeMethods.LMS_SetNCOIndex(_device, LMS_CH_RX, _channel, 0, false) != 0) - { - _isStreaming = false; - throw new ApplicationException(NativeMethods.limesdr_strerror()); - } - } + _isStreaming = false; + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } } } - else - { - _old_centerFrequency = _centerFrequency; - } } catch { - + MessageBox.Show(NativeMethods.limesdr_strerror(), ""); + //throw new ApplicationException(NativeMethods.limesdr_strerror()); } } @@ -533,10 +594,25 @@ public double SampleRate } } - public double Gain + unsafe public double Gain { get { + double[] buffer = new double[1]; + + if (_device != IntPtr.Zero) + { + fixed (double* value = &buffer[0]) + { + if (NativeMethods.LMS_GetNormalizedGain(_device, LMS_CH_RX, _channel, &value[0]) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + } + } + + _gain = buffer[0]; + return _gain; } @@ -548,7 +624,7 @@ public double Gain { if (_device != IntPtr.Zero) { - if (NativeMethods.LMS_SetGaindB(_device, LMS_CH_RX, _channel, _gain) != 0) + if (NativeMethods.LMS_SetNormalizedGain(_device, LMS_CH_RX, _channel, value / 73.0) != 0) { throw new ApplicationException(NativeMethods.limesdr_strerror()); } @@ -578,6 +654,45 @@ public double LPBW } } } + + public void Set_GFIR_BPF_Width(double width) + { + try + { + GFIR_BPF_Width = width; + + if (NativeMethods.LMS_SetGFIRLPF(_device, LMS_CH_RX, _channel, true, width) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + } + catch (Exception ex) + { + Debug.Write(ex.ToString()); + } + } + + public unsafe double ReadTemperature() + { + try + { + double[] buffer = new double[10]; + + fixed (double* buf = &buffer[0]) + if (NativeMethods.LMS_GetChipTemperature(_device, 0, buf) != 0) + { + throw new ApplicationException(NativeMethods.limesdr_strerror()); + } + + return buffer[0]; + } + catch (Exception ex) + { + Debug.Write(ex.ToString()); + + return 0.0; + } + } } public sealed class SamplesAvailableEventArgs : EventArgs diff --git a/SDRSharp.LimeSDR/LimeSDRIO.cs b/SDRSharp.LimeSDR/LimeSDRIO.cs index bc2c6bb..54c43c1 100644 --- a/SDRSharp.LimeSDR/LimeSDRIO.cs +++ b/SDRSharp.LimeSDR/LimeSDRIO.cs @@ -96,7 +96,10 @@ public double Gain { get { - return _gain; + if (_LimeDev != null) + return _LimeDev.Gain; + else + return _gain; } set @@ -104,9 +107,7 @@ public double Gain _gain = (uint)value; if (_LimeDev != null) - { _LimeDev.Gain = _gain; - } } } @@ -160,6 +161,16 @@ public double FreqDiff public ushort LNAgain { + get + { + if (_LimeDev != null) + { + return _LimeDev.LNAgain; + } + else + return 0; + } + set { _lnaGain = value; @@ -173,6 +184,16 @@ public ushort LNAgain public ushort TIAgain { + get + { + if (_LimeDev != null) + { + return _LimeDev.TIAgain; + } + else + return 0; + } + set { _tiaGain = value; @@ -186,6 +207,16 @@ public ushort TIAgain public ushort PGAgain { + get + { + if (_LimeDev != null) + { + return _LimeDev.PGAgain; + } + else + return 0; + } + set { _pgaGain = value; @@ -293,12 +324,15 @@ public void Start(Radio.SamplesAvailableDelegate callback) _LimeDev.Open(RadioName); } + _LimeDev.GFIR_BPF_Width = _gui._GFIR_BPF_Width; _LimeDev.LPBW = _gui.LPBW; _LimeDev.SampleRate = _sampleRate; _LimeDev.Start(_channel, _lpbw, _gain, _ant, _sampleRate, _specOffset); _LimeDev.LPBW = _gui.LPBW; _isStreaming = true; + _gui.btnRadioInfo.Enabled = true; + _gui.btnRadioRefresh.Enabled = false; } catch(Exception ex) { @@ -335,6 +369,8 @@ public void ReStart() _LimeDev.LPBW = _gui.LPBW; _isStreaming = true; + _gui.btnRadioInfo.Enabled = true; + _gui.btnRadioRefresh.Enabled = false; } catch (Exception ex) { @@ -348,6 +384,8 @@ public void Stop() { try { + _gui.btnRadioInfo.Enabled = false; + _gui.btnRadioRefresh.Enabled = true; _isStreaming = false; _gui.grpChannel.Enabled = true; _gui.samplerateComboBox.Enabled = true; @@ -412,6 +450,7 @@ public long Frequency { _frequency = this._LimeDev.Frequency; } + return (long)_frequency; } set @@ -439,8 +478,7 @@ public double Samplerate public bool CanTune { - get - { return true; } + get { return true; } } public long MaximumTunableFrequency diff --git a/SDRSharp.LimeSDR/NativeMethods.cs b/SDRSharp.LimeSDR/NativeMethods.cs index 25ce5f2..d6f3d2b 100644 --- a/SDRSharp.LimeSDR/NativeMethods.cs +++ b/SDRSharp.LimeSDR/NativeMethods.cs @@ -13,31 +13,19 @@ namespace SDRSharp.LimeSDR { - [StructLayout(LayoutKind.Sequential)] - - /**Metadata structure used in sample transfers*/ - public struct lms_stream_meta_t + //Enumeration of LMS7 TEST signal types + public enum lms_testsig_t { - /** - * Timestamp is a value of HW counter with a tick based on sample rate. - * In RX: time when the first sample in the returned buffer was received - * In TX: time when the first sample in the submitted buffer should be send - */ - public UInt64 timestamp; - - /**In TX: wait for the specified HW timestamp before broadcasting data over - * the air - * In RX: wait for the specified HW timestamp before starting to receive - * samples - */ - public bool waitForTimestamp; - - /**Indicates the end of send/receive transaction. Currently has no effect - * @todo force send samples to HW (ignore transfer size) when selected - */ - public bool flushPartialPacket; + LMS_TESTSIG_NONE = 0, ///Properties SDRSharp.LimeSDR SDRSharp.LimeSDR - v4.6 + v4.6.1 512 true publish\ @@ -79,6 +79,27 @@ MinimumRecommendedRules.ruleset false + + true + ..\..\..\Radio\SDR# x64\ + TRACE;DEBUG;WIN64 + true + true + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + ..\..\..\Radio\SDR# x64\ + true + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + WIN64 +