mirror of
https://github.com/UzixLS/sdrsharp-catcontroller.git
synced 2025-07-18 23:01:39 +03:00
TS-50 IF and FA commands
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
obj/
|
obj/
|
||||||
|
Release/
|
||||||
|
ReferencedDLLs/
|
||||||
|
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# sdrsharp-catcontroller
|
||||||
|
|
||||||
|
This plugin allow SDR# to be controlled via serial (COM) interface with subset of TS-50 receiver commands.
|
||||||
|
Supported commands:
|
||||||
|
* IF - get frequency
|
||||||
|
* FA - set frequency
|
||||||
|
|
||||||
|
This plugin based on code by pewusoft (http://users.vline.pl/~pewusoft/)
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>SDRSharp.SerialController</RootNamespace>
|
<RootNamespace>SDRSharp.SerialController</RootNamespace>
|
||||||
<AssemblyName>SDRSharp.SerialController</AssemblyName>
|
<AssemblyName>SDRSharp.SerialController</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<NoWin32Manifest>False</NoWin32Manifest>
|
<NoWin32Manifest>False</NoWin32Manifest>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>..\Release\</OutputPath>
|
<OutputPath>Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
<DebugType>PdbOnly</DebugType>
|
<DebugType>PdbOnly</DebugType>
|
||||||
@ -82,6 +82,15 @@
|
|||||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CSharp">
|
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SDRSharp.Common">
|
||||||
|
<HintPath>ReferencedDLLs\SDRSharp.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SDRSharp.Radio">
|
||||||
|
<HintPath>ReferencedDLLs\SDRSharp.Radio.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
@ -93,18 +102,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="SerialPort.cs" />
|
<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">
|
<!--<Reference Include="SDRSharp.PanView, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>../Common/SDRSharp.PanView.dll</HintPath>
|
<HintPath>../Common/SDRSharp.PanView.dll</HintPath>
|
||||||
</Reference>-->
|
</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">
|
<Compile Include="SerialControllerPanel.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2008
|
# Visual Studio 2012
|
||||||
# SharpDevelop 5.1
|
# SharpDevelop 5.1
|
||||||
|
VisualStudioVersion = 12.0.20827.3
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.SerialController", "SDRSharp.SerialController.csproj", "{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDRSharp.SerialController", "SDRSharp.SerialController.csproj", "{41C6CC2E-5F1D-4BFC-9676-381AD488FCD6}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
6
SerialControllerPanel.Designer.cs
generated
6
SerialControllerPanel.Designer.cs
generated
@ -61,7 +61,7 @@
|
|||||||
this.btnRefreshPorts.Image = ((System.Drawing.Image)(resources.GetObject("btnRefreshPorts.Image")));
|
this.btnRefreshPorts.Image = ((System.Drawing.Image)(resources.GetObject("btnRefreshPorts.Image")));
|
||||||
this.btnRefreshPorts.Location = new System.Drawing.Point(188, 2);
|
this.btnRefreshPorts.Location = new System.Drawing.Point(188, 2);
|
||||||
this.btnRefreshPorts.Name = "btnRefreshPorts";
|
this.btnRefreshPorts.Name = "btnRefreshPorts";
|
||||||
this.btnRefreshPorts.Size = new System.Drawing.Size(30, 23);
|
this.btnRefreshPorts.Size = new System.Drawing.Size(30, 30);
|
||||||
this.btnRefreshPorts.TabIndex = 3;
|
this.btnRefreshPorts.TabIndex = 3;
|
||||||
this.btnRefreshPorts.UseVisualStyleBackColor = true;
|
this.btnRefreshPorts.UseVisualStyleBackColor = true;
|
||||||
this.btnRefreshPorts.Click += new System.EventHandler(this.BtnRefreshPortsClick);
|
this.btnRefreshPorts.Click += new System.EventHandler(this.BtnRefreshPortsClick);
|
||||||
@ -89,8 +89,8 @@
|
|||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(215, 46);
|
this.label1.Size = new System.Drawing.Size(215, 46);
|
||||||
this.label1.TabIndex = 6;
|
this.label1.TabIndex = 6;
|
||||||
this.label1.Text = "This plugin receives AR ONE commands from UniTrunker and sets frequency according" +
|
this.label1.Text = "Accept some TS-50 CAT commands via serial interface. " +
|
||||||
"ly. Made by pewusoft, 2015";
|
"Made by Uzix, 2016. Based on plugin by pewusoft, 2015";
|
||||||
//
|
//
|
||||||
// SerialControllerPanel
|
// SerialControllerPanel
|
||||||
//
|
//
|
||||||
|
@ -45,7 +45,11 @@ namespace SDRSharp.SerialController
|
|||||||
}
|
}
|
||||||
void CbEnableClick(object sender, EventArgs e)
|
void CbEnableClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
cbEnable.Checked = cbEnable.Checked ? _serialPort.openPort(comboPorts.Text) : _serialPort.closePort();
|
if (! _serialPort.IsOpen)
|
||||||
|
_serialPort.openPort(comboPorts.Text);
|
||||||
|
else
|
||||||
|
_serialPort.closePort();
|
||||||
|
cbEnable.Checked = _serialPort.IsOpen;
|
||||||
comboPorts.Enabled = !cbEnable.Checked;
|
comboPorts.Enabled = !cbEnable.Checked;
|
||||||
btnRefreshPorts.Enabled = !cbEnable.Checked;
|
btnRefreshPorts.Enabled = !cbEnable.Checked;
|
||||||
cbLogToFile.Enabled = !cbEnable.Checked;
|
cbLogToFile.Enabled = !cbEnable.Checked;
|
||||||
|
@ -112,10 +112,10 @@
|
|||||||
<value>2.0</value>
|
<value>2.0</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<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">
|
<data name="btnRefreshPorts.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
@ -33,6 +33,7 @@ namespace SDRSharp.SerialController
|
|||||||
_control = control;
|
_control = control;
|
||||||
_serialPort = new SerialPortCtrl();
|
_serialPort = new SerialPortCtrl();
|
||||||
_serialPort.OnFrequencyChange += UpdateFrequency;
|
_serialPort.OnFrequencyChange += UpdateFrequency;
|
||||||
|
_serialPort.OnGetFrequency += GetFrequency;
|
||||||
|
|
||||||
_controlPanel = new SerialControllerPanel(_serialPort);
|
_controlPanel = new SerialControllerPanel(_serialPort);
|
||||||
_controlPanel.readSettings();
|
_controlPanel.readSettings();
|
||||||
@ -41,7 +42,10 @@ namespace SDRSharp.SerialController
|
|||||||
void UpdateFrequency(object sender, long freq) {
|
void UpdateFrequency(object sender, long freq) {
|
||||||
_control.Frequency = freq;
|
_control.Frequency = freq;
|
||||||
_controlPanel.addToLogList(freq.ToString("N0")+" Hz");
|
_controlPanel.addToLogList(freq.ToString("N0")+" Hz");
|
||||||
|
}
|
||||||
|
|
||||||
|
long GetFrequency() {
|
||||||
|
return _control.Frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
@ -20,6 +20,9 @@ namespace SDRSharp.SerialController
|
|||||||
set { this._enableLogging = value; }
|
set { this._enableLogging = value; }
|
||||||
get { return this._enableLogging; }
|
get { return this._enableLogging; }
|
||||||
}
|
}
|
||||||
|
public bool IsOpen {
|
||||||
|
get { return _port != null && _port.IsOpen; }
|
||||||
|
}
|
||||||
|
|
||||||
StreamWriter logger;
|
StreamWriter logger;
|
||||||
SerialPort _port;
|
SerialPort _port;
|
||||||
@ -27,28 +30,30 @@ namespace SDRSharp.SerialController
|
|||||||
public delegate void FrequencyChangeHandler(object sender, long freq);
|
public delegate void FrequencyChangeHandler(object sender, long freq);
|
||||||
public event FrequencyChangeHandler OnFrequencyChange;
|
public event FrequencyChangeHandler OnFrequencyChange;
|
||||||
|
|
||||||
|
public delegate long GetFrequencyHandler();
|
||||||
|
public event GetFrequencyHandler OnGetFrequency;
|
||||||
|
|
||||||
|
|
||||||
public static string[] GetAllPorts()
|
public static string[] GetAllPorts()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return SerialPort.GetPortNames();
|
return SerialPort.GetPortNames();
|
||||||
} catch {
|
} catch (Exception e) {
|
||||||
MessageBox.Show("Exception while getting available serial ports", "SerialController", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Cannot read port list:\n"+e.ToString(), "SerialController", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return new string[0];
|
return new string[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool openPort(string portName) {
|
public bool openPort(string portName) {
|
||||||
try {
|
try {
|
||||||
if (_port != null && _port.IsOpen) {
|
if (_port != null && _port.IsOpen)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (portName == null || (portName.Trim().Equals("")))
|
if (portName == null || (portName.Trim().Equals("")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
|
_port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
|
||||||
_port.DataReceived += Port_DataReceived;
|
_port.DataReceived += new SerialDataReceivedEventHandler( Port_DataReceived );
|
||||||
|
|
||||||
|
|
||||||
if (_port != null) {
|
if (_port != null) {
|
||||||
_port.Open();
|
_port.Open();
|
||||||
@ -59,8 +64,9 @@ namespace SDRSharp.SerialController
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (Exception) {
|
} catch (Exception e) {
|
||||||
MessageBox.Show("Couldn't open port "+portName, "SerialController", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Couldn't open port "+portName+":\n"+e.ToString(), "SerialController",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,15 +93,33 @@ namespace SDRSharp.SerialController
|
|||||||
|
|
||||||
void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||||
{
|
{
|
||||||
if (OnFrequencyChange == null) return;
|
string data = "";
|
||||||
|
while( data.IndexOf(';') < 0 ) {
|
||||||
|
byte[] bytes = new byte[_port.BytesToRead+32];
|
||||||
|
try {
|
||||||
|
_port.Read(bytes, 0, _port.BytesToRead);
|
||||||
|
}
|
||||||
|
catch (Exception) {
|
||||||
|
log("Error reading COM port");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data += System.Text.Encoding.UTF8.GetString(bytes);
|
||||||
|
}
|
||||||
|
data = data.Substring(0, data.IndexOf(';'));
|
||||||
|
|
||||||
string data = _port.ReadLine();
|
// TS-50 command parse
|
||||||
// log commands to file
|
if (data.StartsWith("IF", StringComparison.Ordinal)) {
|
||||||
log("Received on COM port: "+data);
|
long freq = OnGetFrequency();
|
||||||
// AR-ONE RF command parse, as simple as can be, but faster than regex
|
string response = "IF";
|
||||||
if (data.StartsWith("RF", StringComparison.Ordinal)) {
|
response += String.Format("{0:00000000000}", freq);
|
||||||
|
response += "000000000000000000000000;";
|
||||||
|
_port.Write(response);
|
||||||
|
}
|
||||||
|
if (data.StartsWith("FA", StringComparison.Ordinal)) {
|
||||||
long freq;
|
long freq;
|
||||||
if (long.TryParse(data.Substring("RF".Length), out freq)) {
|
if (long.TryParse(data.Substring(2), out freq)) {
|
||||||
|
log("Received on COM port: "+data);
|
||||||
|
if (OnFrequencyChange == null) return;
|
||||||
OnFrequencyChange(this, freq);
|
OnFrequencyChange(this, freq);
|
||||||
log("Changing frequency to: "+freq.ToString("N0"));
|
log("Changing frequency to: "+freq.ToString("N0"));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user