HamBook – Blame information for rev 11

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 office 1 using HamBook.Radios.Generic;
2 using System;
3 using System.Collections.Generic;
4 using System.Drawing;
5 using System.IO.Ports;
6 using System.Linq;
7 using System.Text;
8 using System.Text.RegularExpressions;
9 using System.Threading.Tasks;
10 using static HamBook.Radios.Yaesu.FT_891.Constants;
9 office 11 using RJCP.IO.Ports;
3 office 12  
13 namespace HamBook.Radios.Yaesu.FT_891.CAT
14 {
15 [Radio("Yaesu FT-891")]
16 public class IF : Generic.CAT.IF
17 {
9 office 18 public override CatLength CatLength => new CatLength { Answer = 28, Read = 3 };
11 office 19  
9 office 20 public IF(SerialPortStream serialPort) : base(serialPort)
3 office 21 {
22 }
23  
24 public override Information Read()
25 {
26 SerialPort.Write($"{Name}{Generic.Constants.EOT}");
11 office 27 var buffer = new byte[CatLength.Answer];
28 if (SerialPort.Read(buffer, 0, CatLength.Answer) != CatLength.Answer)
29 {
30 throw new UnexpectedRadioResponseException(Name, buffer);
31 }
3 office 32  
11 office 33 var answer = Constants.Encoding.GetString(buffer);
34 var match = InformationRegex.Match(answer);
35 if (!match.Success)
36 {
37 throw new UnmatchedRadioResponseException(Name, answer);
38 }
39  
3 office 40 var information = new Information
41 {
42 RadioBank = int.Parse(match.Result("${radioBank}")),
43 Frequency = int.Parse(match.Result("${frequency}")),
44 ClarifierDirection = char.Parse(match.Result("${clarifierDirection}")),
45 ClarifierOffset = int.Parse(match.Result("${clarifierOffset}")),
46 Clar = int.Parse(match.Result("${clar}")),
47 RadioMode = char.Parse(match.Result("${mode}")),
48 Storage = (RadioStorage)int.Parse(match.Result("${storage}")),
49 CtcssMode = (CtcssMode)int.Parse(match.Result("${ctcssMode}")),
50 Phase = (RadioPhase)int.Parse(match.Result("${phase}"))
51 };
11 office 52  
3 office 53 return information;
54 }
55 }
56 }