mirror of
https://github.com/UzixLS/sdrsharp-catcontroller.git
synced 2025-07-18 23:01:39 +03:00
improve hamlib compatibility (#3)
This commit is contained in:
@ -22,23 +22,28 @@ namespace SDRSharp.SerialController
|
||||
{DetectorType.LSB, 1},
|
||||
{DetectorType.USB, 2},
|
||||
{DetectorType.CW, 3},
|
||||
{DetectorType.RAW, 4}
|
||||
{DetectorType.RAW, 8}
|
||||
};
|
||||
static readonly Dictionary<uint, DetectorType> int2mode = new Dictionary<uint, DetectorType> {
|
||||
{1, DetectorType.LSB},
|
||||
{2, DetectorType.USB},
|
||||
{3, DetectorType.CW},
|
||||
{4, DetectorType.NFM},
|
||||
{5, DetectorType.AM}
|
||||
{5, DetectorType.AM},
|
||||
{8, DetectorType.RAW}
|
||||
};
|
||||
|
||||
public string EndMarker { get { return ";"; } }
|
||||
|
||||
public int MaxLen { get { return 255; } }
|
||||
|
||||
SerialRadioInterface _radio;
|
||||
bool _DetectorSetFailure;
|
||||
|
||||
|
||||
public Protocol_TS50(SerialRadioInterface radio)
|
||||
{
|
||||
_radio = radio;
|
||||
_DetectorSetFailure = false;
|
||||
}
|
||||
|
||||
public string PktTransmitter(string ChangedProperty)
|
||||
@ -63,22 +68,54 @@ namespace SDRSharp.SerialController
|
||||
response += "IF";
|
||||
response += String.Format("{0:00000000000}", _radio.RadioFrequency);
|
||||
response += "0000000000000000";
|
||||
response += mode2int[_radio.RadioMode];
|
||||
if ( _DetectorSetFailure)
|
||||
response += 0;
|
||||
else
|
||||
response += mode2int[_radio.RadioMode];
|
||||
response += "0000000";
|
||||
response += EndMarker;
|
||||
}
|
||||
if (ReceivedData.StartsWith("FA", StringComparison.Ordinal)) {
|
||||
else if (ReceivedData == "FA") {
|
||||
response += "FA";
|
||||
response += String.Format("{0:00000000000}", _radio.RadioFrequency);
|
||||
response += EndMarker;
|
||||
}
|
||||
else if (ReceivedData.StartsWith("FA", StringComparison.Ordinal)) {
|
||||
long freq;
|
||||
if (long.TryParse(ReceivedData.Substring(2), out freq)) {
|
||||
_radio.RadioFrequency = freq;
|
||||
}
|
||||
}
|
||||
if (ReceivedData.StartsWith("MD", StringComparison.Ordinal)) {
|
||||
else if (ReceivedData == "MD") {
|
||||
response += "MD";
|
||||
if (_DetectorSetFailure)
|
||||
response += 0;
|
||||
else
|
||||
response += mode2int[_radio.RadioMode];
|
||||
response += EndMarker;
|
||||
}
|
||||
else if (ReceivedData.StartsWith("MD", StringComparison.Ordinal)) {
|
||||
uint mode;
|
||||
if (uint.TryParse(ReceivedData.Substring(2), out mode)) {
|
||||
_radio.RadioMode = int2mode[mode];
|
||||
try {
|
||||
_radio.RadioMode = int2mode[mode];
|
||||
_DetectorSetFailure = false;
|
||||
}
|
||||
catch {
|
||||
_DetectorSetFailure = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ReceivedData == "ID") {
|
||||
response += "ID";
|
||||
response += "021"; //XXX: TS-590S value, idk what's should be there for TS-50
|
||||
response += EndMarker;
|
||||
}
|
||||
else if (ReceivedData == "RX") {
|
||||
response += "RX";
|
||||
response += EndMarker;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user