mirror of
https://github.com/UzixLS/sdrsharp-catcontroller.git
synced 2025-07-18 23:01:39 +03:00
initial (SerialController-1.2)
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
obj/
|
||||||
|
|
1
MagicString.txt
Normal file
1
MagicString.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
<add key="SerialController" value="SDRSharp.SerialController.SerialControllerPlugin, SDRSharp.SerialController" />
|
36
Properties/AssemblyInfo.cs
Normal file
36
Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("SerialController")]
|
||||||
|
[assembly: AssemblyDescription("Serial port controller for SDR#")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("SerialController")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Pawel Walczak 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("a69bd5ae-f03a-4dcf-856d-4303bf64e2a3")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
130
SDRSharp.SerialController.csproj
Normal file
130
SDRSharp.SerialController.csproj
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>SDRSharp.SerialController</RootNamespace>
|
||||||
|
<AssemblyName>SDRSharp.SerialController</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
<NoWin32Manifest>False</NoWin32Manifest>
|
||||||
|
<SignAssembly>False</SignAssembly>
|
||||||
|
<DelaySign>False</DelaySign>
|
||||||
|
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||||
|
<NoStdLib>False</NoStdLib>
|
||||||
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
|
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>..\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>..\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
<DebugType>PdbOnly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
|
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
|
||||||
|
<StartAction>Project</StartAction>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||||
|
<BaseAddress>4194304</BaseAddress>
|
||||||
|
<RegisterForComInterop>False</RegisterForComInterop>
|
||||||
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="SerialPort.cs" />
|
||||||
|
<Reference Include="SDRSharp.Common, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>../Common/SDRSharp.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<!--<Reference Include="SDRSharp.PanView, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>../Common/SDRSharp.PanView.dll</HintPath>
|
||||||
|
</Reference>-->
|
||||||
|
<Reference Include="SDRSharp.Radio, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>../Common/SDRSharp.Radio.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Compile Include="SerialControllerPanel.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="SerialControllerPanel.Designer.cs">
|
||||||
|
<DependentUpon>SerialControllerPanel.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="SerialControllerPlugin.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="SerialControllerPanel.resx">
|
||||||
|
<DependentUpon>SerialControllerPanel.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
6
SDRSharp.SerialController.csproj.user
Normal file
6
SDRSharp.SerialController.csproj.user
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
18
SDRSharp.SerialController.sln
Normal file
18
SDRSharp.SerialController.sln
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
# SharpDevelop 5.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.SerialController", "SDRSharp.SerialController.csproj", "{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}.Debug|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}.Debug|Any CPU.Build.0 = Release|x86
|
||||||
|
{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}.Release|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}.Release|Any CPU.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
120
SerialControllerPanel.Designer.cs
generated
Normal file
120
SerialControllerPanel.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
namespace SDRSharp.SerialController
|
||||||
|
{
|
||||||
|
partial class SerialControllerPanel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SerialControllerPanel));
|
||||||
|
this.cbEnable = new System.Windows.Forms.CheckBox();
|
||||||
|
this.comboPorts = new System.Windows.Forms.ComboBox();
|
||||||
|
this.btnRefreshPorts = new System.Windows.Forms.Button();
|
||||||
|
this.cbLogToFile = new System.Windows.Forms.CheckBox();
|
||||||
|
this.lbLog = new System.Windows.Forms.ListBox();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// cbEnable
|
||||||
|
//
|
||||||
|
this.cbEnable.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.cbEnable.Name = "cbEnable";
|
||||||
|
this.cbEnable.Size = new System.Drawing.Size(74, 22);
|
||||||
|
this.cbEnable.TabIndex = 1;
|
||||||
|
this.cbEnable.Text = "Enable";
|
||||||
|
this.cbEnable.UseVisualStyleBackColor = true;
|
||||||
|
this.cbEnable.Click += new System.EventHandler(this.CbEnableClick);
|
||||||
|
this.cbEnable.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CbEnableKeyDown);
|
||||||
|
//
|
||||||
|
// comboPorts
|
||||||
|
//
|
||||||
|
this.comboPorts.FormattingEnabled = true;
|
||||||
|
this.comboPorts.Location = new System.Drawing.Point(83, 3);
|
||||||
|
this.comboPorts.Name = "comboPorts";
|
||||||
|
this.comboPorts.Size = new System.Drawing.Size(100, 21);
|
||||||
|
this.comboPorts.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// btnRefreshPorts
|
||||||
|
//
|
||||||
|
this.btnRefreshPorts.Image = ((System.Drawing.Image)(resources.GetObject("btnRefreshPorts.Image")));
|
||||||
|
this.btnRefreshPorts.Location = new System.Drawing.Point(188, 2);
|
||||||
|
this.btnRefreshPorts.Name = "btnRefreshPorts";
|
||||||
|
this.btnRefreshPorts.Size = new System.Drawing.Size(30, 23);
|
||||||
|
this.btnRefreshPorts.TabIndex = 3;
|
||||||
|
this.btnRefreshPorts.UseVisualStyleBackColor = true;
|
||||||
|
this.btnRefreshPorts.Click += new System.EventHandler(this.BtnRefreshPortsClick);
|
||||||
|
//
|
||||||
|
// cbLogToFile
|
||||||
|
//
|
||||||
|
this.cbLogToFile.Location = new System.Drawing.Point(3, 30);
|
||||||
|
this.cbLogToFile.Name = "cbLogToFile";
|
||||||
|
this.cbLogToFile.Size = new System.Drawing.Size(104, 24);
|
||||||
|
this.cbLogToFile.TabIndex = 4;
|
||||||
|
this.cbLogToFile.Text = "Log to file";
|
||||||
|
this.cbLogToFile.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// lbLog
|
||||||
|
//
|
||||||
|
this.lbLog.FormattingEnabled = true;
|
||||||
|
this.lbLog.Location = new System.Drawing.Point(3, 60);
|
||||||
|
this.lbLog.Name = "lbLog";
|
||||||
|
this.lbLog.Size = new System.Drawing.Size(215, 69);
|
||||||
|
this.lbLog.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.Location = new System.Drawing.Point(3, 132);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(215, 46);
|
||||||
|
this.label1.TabIndex = 6;
|
||||||
|
this.label1.Text = "This plugin receives AR ONE commands from UniTrunker and sets frequency according" +
|
||||||
|
"ly. Made by pewusoft, 2015";
|
||||||
|
//
|
||||||
|
// SerialControllerPanel
|
||||||
|
//
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.lbLog);
|
||||||
|
this.Controls.Add(this.cbLogToFile);
|
||||||
|
this.Controls.Add(this.btnRefreshPorts);
|
||||||
|
this.Controls.Add(this.comboPorts);
|
||||||
|
this.Controls.Add(this.cbEnable);
|
||||||
|
this.Name = "SerialControllerPanel";
|
||||||
|
this.Size = new System.Drawing.Size(222, 201);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.CheckBox cbEnable;
|
||||||
|
private System.Windows.Forms.ComboBox comboPorts;
|
||||||
|
private System.Windows.Forms.Button btnRefreshPorts;
|
||||||
|
private System.Windows.Forms.CheckBox cbLogToFile;
|
||||||
|
private System.Windows.Forms.ListBox lbLog;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
59
SerialControllerPanel.cs
Normal file
59
SerialControllerPanel.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using SDRSharp.Radio;
|
||||||
|
|
||||||
|
namespace SDRSharp.SerialController
|
||||||
|
{
|
||||||
|
public partial class SerialControllerPanel : UserControl
|
||||||
|
{
|
||||||
|
readonly SerialPortCtrl _serialPort;
|
||||||
|
|
||||||
|
public SerialControllerPanel(SerialPortCtrl serialPort)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serialPort = serialPort;
|
||||||
|
|
||||||
|
BtnRefreshPortsClick(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BtnRefreshPortsClick(object sender, EventArgs e) {
|
||||||
|
comboPorts.Items.Clear();
|
||||||
|
comboPorts.Items.AddRange(SerialPortCtrl.GetAllPorts());
|
||||||
|
if (comboPorts.Items.Count > 0)
|
||||||
|
comboPorts.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToLogList(String log) {
|
||||||
|
lbLog.Items.Add(log);
|
||||||
|
// scroll to bottom
|
||||||
|
lbLog.SelectedIndex = lbLog.Items.Count - 1;
|
||||||
|
lbLog.SelectedIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readSettings() {
|
||||||
|
comboPorts.Text = Utils.GetStringSetting("serialControlComPort", "");
|
||||||
|
cbLogToFile.Checked = Utils.GetBooleanSetting("serialControlLogToFile");
|
||||||
|
cbEnable.Checked = Utils.GetBooleanSetting("serialControlEnable");
|
||||||
|
CbEnableClick(null,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveSettings() {
|
||||||
|
Utils.SaveSetting("serialControlComPort", comboPorts.Text);
|
||||||
|
Utils.SaveSetting("serialControlLogToFile", cbLogToFile.Checked);
|
||||||
|
Utils.SaveSetting("serialControlEnable", cbEnable.Checked);
|
||||||
|
}
|
||||||
|
void CbEnableClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
cbEnable.Checked = cbEnable.Checked ? _serialPort.openPort(comboPorts.Text) : _serialPort.closePort();
|
||||||
|
comboPorts.Enabled = !cbEnable.Checked;
|
||||||
|
btnRefreshPorts.Enabled = !cbEnable.Checked;
|
||||||
|
cbLogToFile.Enabled = !cbEnable.Checked;
|
||||||
|
_serialPort.EnableLogging = cbLogToFile.Checked;
|
||||||
|
}
|
||||||
|
void CbEnableKeyDown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
CbEnableClick(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
139
SerialControllerPanel.resx
Normal file
139
SerialControllerPanel.resx
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<data name="btnRefreshPorts.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
|
||||||
|
dHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAALHSURBVDhPbZNdSFNhGMctEiqzhG4q8qpuqtt0anYR
|
||||||
|
EV1kH2BRIFFdqJsfUFKpERZlJFFpmJSUpLGdzdScZY7h1xTLZrpqU5ypS3SbzTmx5tlqbufp/548Q6SL
|
||||||
|
H7zv8/F//+9z3hNBRGH2pitjkxTqF0lZalt8psqXqFA7sG5DPBVErqgtBDHhQFy68kSCnPPJywyBUq2F
|
||||||
|
NN3fSdNlo/KmQTp3V78gy1TNo+GMWJuhzMCawCZJbVeiguPvN1ioqn2MajrGqfmTgzotLuofn6OhyXnq
|
||||||
|
NE/TkfxGHs4MBy/V+SESRN9GUQBWnynKDKG8p+8pOVtDSBKsB8/e0XlrWkcEq/0njTp/0fgPL5WoTaGP
|
||||||
|
1hmW/wOBaFEA1r0HLtZRck6tgASPxBWwFRxKUHADF0r0/MComybdPDnnfCKoCyAfJd2fNS7KH/VW4a5O
|
||||||
|
JHawuAT255mr3mEXfbC6aWqWhwDHBNZLBcGUwrdFV6s+7zl9u3Uz9quXNa+Bw57S+i+BaZzMrvLPAbeI
|
||||||
|
3DqpKFpqWAly1YAOX274nZLf6BcpaPSzGFgrFbGBCEuEAJswO0EPYsGW/7Cd9UoCQYeHJ4fHR3bc77lu
|
||||||
|
OCSTcxOIx0hOJIqUQ9vyKgcSWQ/YIAbZN2X36hl2k3FkhlljTrKWN2IfFZehcuVUGB+k3tB1Y8/qIsUk
|
||||||
|
Jh9iAmy6djjpMjvpaKGWxyfsQ1H8kkBWcnat5/j1FvYJBZlcFWBxUQBTDrHHUvFmUJhwLYgPpn/MQ6UN
|
||||||
|
ZiGlQMvj5EW8VALC/txaQoyJaMICcCCkFev8eKaDx641LTT3TZHx2yy1fZ0mrXGKqjtsVFJnplsqEz18
|
||||||
|
bSEcyB7b7rAAuw+ay5fWJ2WZ3Nypm++8xZyJnrRYqVI/SvfqLZT7uDvIfjjMLI3VLhd4CVZJQawjQSps
|
||||||
|
dmAOLjQEsLbvy1a/QnynVEdEEX8BQVqGDn9sKuMAAAAASUVORK5CYII=
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
53
SerialControllerPlugin.cs
Normal file
53
SerialControllerPlugin.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using SDRSharp.Common;
|
||||||
|
|
||||||
|
namespace SDRSharp.SerialController
|
||||||
|
{
|
||||||
|
public class SerialControllerPlugin: ISharpPlugin
|
||||||
|
{
|
||||||
|
private const string _displayName = "SerialController";
|
||||||
|
|
||||||
|
private SerialControllerPanel _controlPanel;
|
||||||
|
private SerialPortCtrl _serialPort;
|
||||||
|
private ISharpControl _control;
|
||||||
|
|
||||||
|
public string DisplayName
|
||||||
|
{
|
||||||
|
get { return _displayName; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasGui
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserControl Gui
|
||||||
|
{
|
||||||
|
get { return _controlPanel; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(ISharpControl control)
|
||||||
|
{
|
||||||
|
_control = control;
|
||||||
|
_serialPort = new SerialPortCtrl();
|
||||||
|
_serialPort.OnFrequencyChange += UpdateFrequency;
|
||||||
|
|
||||||
|
_controlPanel = new SerialControllerPanel(_serialPort);
|
||||||
|
_controlPanel.readSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateFrequency(object sender, long freq) {
|
||||||
|
_control.Frequency = freq;
|
||||||
|
_controlPanel.addToLogList(freq.ToString("N0")+" Hz");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
_serialPort.closePort();
|
||||||
|
_controlPanel.saveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
138
SerialPort.cs
Normal file
138
SerialPort.cs
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Author: Pawel Walczak (pewusoft)
|
||||||
|
* Date: 2015-01-12 20:50
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.IO.Ports;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace SDRSharp.SerialController
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Description of SerialPort.
|
||||||
|
/// </summary>
|
||||||
|
public class SerialPortCtrl
|
||||||
|
{
|
||||||
|
bool _enableLogging = true;
|
||||||
|
public bool EnableLogging {
|
||||||
|
set { this._enableLogging = value; }
|
||||||
|
get { return this._enableLogging; }
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamWriter logger;
|
||||||
|
SerialPort _port;
|
||||||
|
|
||||||
|
public delegate void FrequencyChangeHandler(object sender, long freq);
|
||||||
|
public event FrequencyChangeHandler OnFrequencyChange;
|
||||||
|
|
||||||
|
public static string[] GetAllPorts()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return SerialPort.GetPortNames();
|
||||||
|
} catch {
|
||||||
|
MessageBox.Show("Exception while getting available serial ports", "SerialController", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return new string[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool openPort(string portName) {
|
||||||
|
try {
|
||||||
|
if (_port != null && _port.IsOpen) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (portName == null || (portName.Trim().Equals("")))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
|
||||||
|
_port.DataReceived += Port_DataReceived;
|
||||||
|
|
||||||
|
|
||||||
|
if (_port != null) {
|
||||||
|
_port.Open();
|
||||||
|
if (_enableLogging) {
|
||||||
|
prepareLogger();
|
||||||
|
log("Port " + _port.PortName + " opened");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (Exception) {
|
||||||
|
MessageBox.Show("Couldn't open port "+portName, "SerialController", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool closePort() {
|
||||||
|
if (_port != null) {
|
||||||
|
if (_port.IsOpen) {
|
||||||
|
try {
|
||||||
|
_port.Close();
|
||||||
|
if (_enableLogging) {
|
||||||
|
log("Port " + _port.PortName + " closed");
|
||||||
|
closeLogger();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (IOException) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
if (OnFrequencyChange == null) return;
|
||||||
|
|
||||||
|
string data = _port.ReadLine();
|
||||||
|
// log commands to file
|
||||||
|
log("Received on COM port: "+data);
|
||||||
|
// AR-ONE RF command parse, as simple as can be, but faster than regex
|
||||||
|
if (data.StartsWith("RF", StringComparison.Ordinal)) {
|
||||||
|
long freq;
|
||||||
|
if (long.TryParse(data.Substring("RF".Length), out freq)) {
|
||||||
|
OnFrequencyChange(this, freq);
|
||||||
|
log("Changing frequency to: "+freq.ToString("N0"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void log(String str) {
|
||||||
|
if (logger!=null) {
|
||||||
|
logger.WriteLine("[" + DateTime.Now + "]: " + str.Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void prepareLogger() {
|
||||||
|
try {
|
||||||
|
if (logger != null) {
|
||||||
|
logger.Close();
|
||||||
|
}
|
||||||
|
logger = new StreamWriter(new FileStream("serial.log",
|
||||||
|
FileMode.Append,
|
||||||
|
FileAccess.Write,
|
||||||
|
FileShare.ReadWrite,
|
||||||
|
1024,
|
||||||
|
FileOptions.WriteThrough));
|
||||||
|
logger.AutoFlush = true;
|
||||||
|
} catch (Exception) {
|
||||||
|
logger = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void closeLogger() {
|
||||||
|
try {
|
||||||
|
if (logger != null) {
|
||||||
|
logger.Close();
|
||||||
|
}
|
||||||
|
logger = null;
|
||||||
|
} catch (Exception) {
|
||||||
|
logger = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
view-refresh.png
Normal file
BIN
view-refresh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 912 B |
Reference in New Issue
Block a user