HamBook – Rev 3
?pathlinks?
using System;
using System.Collections.Generic;
using System.Drawing;
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 FB : Generic.CAT.FB
{
private static readonly Regex readRegex = new Regex(@"^FB(?<frequency>[0-9]{9})$", RegexOptions.Compiled);
public FB(SerialPort serialPort) : base(serialPort)
{
}
public override void Set(int frequency)
{
var fb = frequency.ToString("000000000");
SerialPort.Write($"{Name}{fb}{Generic.Constants.EOT}");
}
public override int Read()
{
SerialPort.Write($"{Name}{Generic.Constants.EOT}");
var result = SerialPort.ReadTo(Generic.Constants.EOT);
var match = readRegex.Match(result);
return int.Parse(match.Result("${frequency}"));
}
}
}