HamBook – Rev 3
?pathlinks?
using HamBook.Radios.Generic;
using HamBook.Radios.Generic.CAT;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static HamBook.Radios.Yaesu.FT_891.Constants;
namespace HamBook.Radios.Yaesu.FT_891
{
[Radio("Yaesu FT-891")]
public class SQ : HamBook.Radios.Generic.CAT.SQ
{
private static readonly Regex readRegex = new Regex(@"^SQ0(?<squelch>[0-9]{3})$", RegexOptions.Compiled);
public SQ(SerialPort serialPort) : base(serialPort)
{
}
public override int GetDefault()
{
return SQUELCH_MIN_STEP;
}
public override int Read()
{
SerialPort.Write($"{Name}0{Generic.Constants.EOT}");
var result = SerialPort.ReadTo(Generic.Constants.EOT);
var match = readRegex.Match(result);
var level = int.Parse(match.Result("${squelch}"));
return level;
}
public override void Set(int level)
{
SerialPort.Write($"{Name}0{level.ToString("000")}{Generic.Constants.EOT}");
}
}
}