HamBook – Rev 7
?pathlinks?
using HamBook.Radios.Generic;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO.Ports;
using System.Linq;
using System.Reflection;
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 MD : Generic.CAT.MD
{
private static readonly Regex readRegex = new Regex(@"^MD0(?<mode>[123456789ABCD]){1}$", RegexOptions.Compiled);
public MD(SerialPort serialPort) : base(serialPort)
{
}
public override bool Set(RadioMode radioMode)
{
SerialPort.Write($"{Name}0{radioMode.Mode}{Generic.Constants.EOT}");
return Read() == radioMode;
}
public override RadioMode Read()
{
SerialPort.Write($"{Name}0{Generic.Constants.EOT}");
var result = SerialPort.ReadTo(Generic.Constants.EOT);
var match = readRegex.Match(result);
var radioMode = char.Parse(match.Result("${mode}"));
return radioMode;
}
}
}