forked from kvamtroe/hamlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.multicast
187 lines (173 loc) · 5.58 KB
/
README.multicast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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)
Version=20210429 1.0.0 (version YYYYMMDD)
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
{
"__comment1__": "customizable rig identification -- will allow multiple rigs to be on the multicast",
"ID": "Rig#1",
"VFOs": [
{
"Name": "VFOA",
"Freq": 14074000,
"Mode": "USB",
"Width": 5000,
"RX": true,
"TX": false
},
{
"Name": "VFOB",
"Freq": 14076000,
"Mode": "USB",
"Width": 5000,
"RX": false,
"TX": false
}],
"__comment_spectra__": "Rigs that have spectrum output may include this array data",
"Spectra": [
{
"Name": "Main",
"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
},
{
"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
}],
LastCommand {
"ID": "MyApp 123",
"Command": "set_freq VFOA 14074000".
"Status": "OK"
},
"PTT" : false,
"Split": true,
"SatMode": false,
"Rig": "Dummy",
"App": "Hamlib",
"__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";
"__comment_seq__": "Seq is 1-up sequence number 32-bit -- wraps around to 1 from 2^32-1",
"Seq": 1,
"__comment_crc__": "32-bit CRC of entire JSON record replacing the CRC value with 0x00000000",
"ErrorMsg": "OK",
"CRC": "0x00000000"
}
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.
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;
}
LastCommand {
public string ID; // an application name plus sequence number recommended
public string Command;
public string Status;
}
public string ID;
public List<VFO> VFOs { get; set; }
public bool PTT;
public bool Split;
public bool SatMode;
public string Rig;
public string App;
public string Version;
public string Status;
public UInt32 Seq;
public string CRC;
public SpectrumClass Spectrum { get; set; }
public string ErrorMsg;
}
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;
}
}
}