HamBook – Rev 7
?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;
using System.Threading.Tasks;
using static HamBook.Radios.Yaesu.FT_891.Constants;
namespace HamBook.Radios.Yaesu.FT_891
{
[Radio("Yaesu FT-891")]
public class FA : Generic.CAT.FA
{
private static readonly Regex readRegex = new Regex(@"^FA(?<frequency>[0-9]{9})$", RegexOptions.Compiled);
public FA(SerialPort serialPort) : base(serialPort)
{
}
public override bool Set(int frequency)
{
var fa = frequency.ToString("000000000");
SerialPort.Write($"{Name}{fa}{Generic.Constants.EOT}");
return Read() == frequency;
}
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}"));
}
}
}