2021-05-09 18:48:03 +00:00
|
|
|
Planned for version 4.3 -- comments/suggestions about this are more than welcome
|
|
|
|
Multicast UDP broadcast on port 4531 (one below rigctld 4532)
|
|
|
|
Bidirectional rig control and status
|
|
|
|
Choice of token pairs or JSON
|
|
|
|
All packets will be tagged with ID=[unique name] -- so multiple rigs can broadcast/rx on the same port
|
|
|
|
|
|
|
|
|
|
|
|
Broadcast packet contents to be based on get_rig_info output
|
|
|
|
This will be the text format of name=value pairs
|
|
|
|
Can be multiple VFO lines
|
|
|
|
Parsers should allow for unknown tags that may be added in the future
|
|
|
|
|
|
|
|
Rig command: \get_rig_info
|
|
|
|
Rig command: \get_rig_info
|
|
|
|
VFO=Main Freq=145000000 Mode=None Width=0 RX=1 TX=1
|
|
|
|
VFO=VFOB Freq=145000000 Mode=FM Width=15000 RX=0 TX=0
|
|
|
|
Split=0 SatMode=0
|
|
|
|
PTT=1 (1=On, 0=Off)
|
|
|
|
Rig=Dummy (name of connected rig)
|
|
|
|
App=Hamlib (name of application providing the packet)
|
2021-05-21 17:33:51 +00:00
|
|
|
Version=20210429 1.0.0 (version YYYYMMDD)
|
2021-05-09 18:48:03 +00:00
|
|
|
Status=OK (possible values OK, Offline, Error)
|
|
|
|
ErrorMsg=msg text (pipe delimited multi-line error message)
|
|
|
|
CRC=0xf49f4708 (this is just an example CRC and not accurate for this example)
|
|
|
|
|
|
|
|
Example JSON
|
|
|
|
{
|
2021-05-18 13:58:21 +00:00
|
|
|
"__comment1__": "customizable rig identification -- will allow multiple rigs to be on the multicast",
|
|
|
|
"ID": "Rig#1",
|
2021-05-20 21:00:03 +00:00
|
|
|
"VFOs": [
|
2021-05-18 13:58:21 +00:00
|
|
|
{
|
2021-05-20 21:00:03 +00:00
|
|
|
"Name": "VFOA",
|
2021-05-18 13:58:21 +00:00
|
|
|
"Freq": 14074000,
|
2021-05-09 18:48:03 +00:00
|
|
|
"Mode": "USB",
|
2021-05-18 13:58:21 +00:00
|
|
|
"Width": 5000,
|
2021-05-20 21:32:43 +00:00
|
|
|
"RX": true,
|
|
|
|
"TX": false
|
2021-05-09 18:48:03 +00:00
|
|
|
},
|
2021-05-18 13:58:21 +00:00
|
|
|
{
|
2021-05-20 21:00:03 +00:00
|
|
|
"Name": "VFOB",
|
2021-05-09 18:48:03 +00:00
|
|
|
"Freq": 14076000,
|
|
|
|
"Mode": "USB",
|
|
|
|
"Width": 5000,
|
2021-05-20 21:32:43 +00:00
|
|
|
"RX": false,
|
|
|
|
"TX": false
|
2021-05-18 13:58:21 +00:00
|
|
|
}],
|
2021-05-19 15:29:33 +00:00
|
|
|
|
2021-05-25 14:28:20 +00:00
|
|
|
"__comment_spectra__": "Rigs that have spectrum output may include this array data",
|
|
|
|
"Spectra": [
|
|
|
|
{
|
|
|
|
"Name": "Main",
|
2021-05-19 15:29:33 +00:00
|
|
|
"Length": 475,
|
|
|
|
"__comment_spectrum_data__": "2-char hex bytes so data len=2*Length",
|
|
|
|
"Data": "00AAFF75BD2AAA...",
|
|
|
|
"Type": "FIXED|CENTER",
|
|
|
|
"MinLevel": 0,
|
|
|
|
"MaxLevel": 140,
|
|
|
|
"MinStrength": -100,
|
|
|
|
"MaxStrength": 0,
|
|
|
|
|
2021-05-20 21:00:03 +00:00
|
|
|
"__comment_spectrum_center__": "If Type=CENTER, the following fields will be present:",
|
2021-05-19 15:29:33 +00:00
|
|
|
"CenterFreq": 14267000,
|
|
|
|
"Span": 25000,
|
|
|
|
|
2021-05-20 21:00:03 +00:00
|
|
|
"__comment_spectrum_fixed__": "If SpectrumType=FIXED, the following fields will be present:",
|
2021-05-19 15:29:33 +00:00
|
|
|
"LowFreq": 14000000,
|
|
|
|
"HighFreq": 14250000
|
2021-05-19 18:00:37 +00:00
|
|
|
},
|
2021-05-25 14:28:20 +00:00
|
|
|
{
|
|
|
|
"Name": "Sub",
|
|
|
|
"Length": 475,
|
|
|
|
"__comment_spectrum_data__": "2-char hex bytes so data len=2*Length",
|
|
|
|
"Data": "00AAFF75BD2AAA...",
|
|
|
|
"Type": "FIXED|CENTER",
|
|
|
|
"MinLevel": 0,
|
|
|
|
"MaxLevel": 140,
|
|
|
|
"MinStrength": -100,
|
|
|
|
"MaxStrength": 0,
|
|
|
|
|
|
|
|
"__comment_spectrum_center__": "If Type=CENTER, the following fields will be present:",
|
|
|
|
"CenterFreq": 14267000,
|
|
|
|
"Span": 25000,
|
|
|
|
|
|
|
|
"__comment_spectrum_fixed__": "If SpectrumType=FIXED, the following fields will be present:",
|
|
|
|
"LowFreq": 14000000,
|
|
|
|
"HighFreq": 14250000
|
|
|
|
}],
|
2021-05-22 21:55:18 +00:00
|
|
|
LastCommand {
|
|
|
|
"ID": "MyApp 123",
|
|
|
|
"Command": "set_freq VFOA 14074000".
|
|
|
|
"Status": "OK"
|
|
|
|
},
|
2021-05-21 17:33:51 +00:00
|
|
|
"PTT" : false,
|
2021-05-20 21:32:43 +00:00
|
|
|
"Split": true,
|
|
|
|
"SatMode": false,
|
2021-05-09 18:48:03 +00:00
|
|
|
"Rig": "Dummy",
|
|
|
|
"App": "Hamlib",
|
2021-05-21 17:33:51 +00:00
|
|
|
"__comment_version__": "protocol version YYYYMMDD x.x.x, 1.0.0 will be used when this is implemented",
|
|
|
|
"Version": "20210521 0.0.0",
|
|
|
|
"Status": "OK";
|
2021-05-18 13:58:21 +00:00
|
|
|
"__comment_seq__": "Seq is 1-up sequence number 32-bit -- wraps around to 1 from 2^32-1",
|
|
|
|
"Seq": 1,
|
2021-05-19 15:29:33 +00:00
|
|
|
"__comment_crc__": "32-bit CRC of entire JSON record replacing the CRC value with 0x00000000",
|
2021-05-21 17:33:51 +00:00
|
|
|
"ErrorMsg": "OK",
|
2021-05-19 15:29:33 +00:00
|
|
|
"CRC": "0x00000000"
|
2021-05-09 18:48:03 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 21:00:03 +00:00
|
|
|
Will be able to set freq, mode, width, ptt, satmode, and split to start since those are common to many apps.
|
|
|
|
More functions will be added as time goes on.
|
2021-05-20 21:32:43 +00:00
|
|
|
|
|
|
|
C# Json Deserialize Example -- beginning of a HamlibMultiCast client
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
namespace HamlibMultiCast
|
|
|
|
{
|
|
|
|
public class HamlibMulticastClient
|
|
|
|
{
|
|
|
|
public class VFO
|
|
|
|
{
|
|
|
|
public string Name;
|
|
|
|
public ulong Freq;
|
|
|
|
public string Mode;
|
|
|
|
public int Width;
|
|
|
|
public bool RX;
|
|
|
|
public bool TX;
|
|
|
|
}
|
|
|
|
public class SpectrumClass
|
|
|
|
{
|
|
|
|
public int Length;
|
|
|
|
public string Data;
|
|
|
|
public string Type;
|
|
|
|
public int MinLevel;
|
|
|
|
public int MaxLevel;
|
|
|
|
public int MinStrength;
|
|
|
|
public int MaxStrength;
|
|
|
|
public double CenterFreq;
|
|
|
|
public int Span;
|
|
|
|
public double LowFreq;
|
|
|
|
public double HighFreq;
|
|
|
|
}
|
2021-05-22 21:55:18 +00:00
|
|
|
LastCommand {
|
|
|
|
public string ID; // an application name plus sequence number recommended
|
|
|
|
public string Command;
|
|
|
|
public string Status;
|
|
|
|
}
|
2021-05-20 21:32:43 +00:00
|
|
|
public string ID;
|
|
|
|
public List<VFO> VFOs { get; set; }
|
2021-05-21 17:33:51 +00:00
|
|
|
public bool PTT;
|
2021-05-20 21:32:43 +00:00
|
|
|
public bool Split;
|
|
|
|
public bool SatMode;
|
|
|
|
public string Rig;
|
|
|
|
public string App;
|
|
|
|
public string Version;
|
2021-05-21 17:33:51 +00:00
|
|
|
public string Status;
|
2021-05-20 21:32:43 +00:00
|
|
|
public UInt32 Seq;
|
|
|
|
public string CRC;
|
|
|
|
public SpectrumClass Spectrum { get; set; }
|
2021-05-21 17:33:51 +00:00
|
|
|
public string ErrorMsg;
|
2021-05-20 21:32:43 +00:00
|
|
|
}
|
|
|
|
class Program
|
|
|
|
{
|
|
|
|
static int Main(string[] args)
|
|
|
|
{
|
|
|
|
Console.WriteLine("HamlibMultiCast Test Json Deserialize");
|
|
|
|
ITraceWriter traceWriter = new MemoryTraceWriter();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
string json = File.ReadAllText("test.json");
|
|
|
|
var client = JsonConvert.DeserializeObject<HamlibMulticastClient>(json, new JsonSerializerSettings { TraceWriter = traceWriter, Converters = { new JavaScriptDateTimeConverter() } });
|
|
|
|
Console.WriteLine(traceWriter);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|