HamBook – Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 using HamBook.Radios.Generic;
2 using Newtonsoft.Json.Linq;
3 using System;
4 using System.Collections.Concurrent;
5 using System.Collections.Generic;
6 using System.ComponentModel;
7 using System.IO.Ports;
8 using System.Linq;
9 using System.Reflection;
10 using System.Text;
11 using System.Text.RegularExpressions;
12 using System.Threading.Tasks;
13 using static HamBook.Radios.Yaesu.FT_891.Constants;
14  
15 namespace HamBook.Radios.Yaesu.FT_891
16 {
17 [Radio("Yaesu FT-891")]
18 public class MD : Generic.CAT.MD
19 {
3 office 20 private static readonly Regex readRegex = new Regex(@"^MD0(?<mode>[123456789ABCD]){1}$", RegexOptions.Compiled);
1 office 21  
22 public MD(SerialPort serialPort) : base(serialPort)
23 {
24 }
25  
3 office 26 public override void Set(RadioMode radioMode)
1 office 27 {
3 office 28 SerialPort.Write($"{Name}0{radioMode.Mode}{Generic.Constants.EOT}");
1 office 29 }
30  
31 public override RadioMode Read()
32 {
3 office 33 SerialPort.Write($"{Name}0{Generic.Constants.EOT}");
34 var result = SerialPort.ReadTo(Generic.Constants.EOT);
1 office 35 var match = readRegex.Match(result);
3 office 36 var radioMode = char.Parse(match.Result("${mode}"));
37 return radioMode;
1 office 38 }
39 }
40 }