HamBook – Blame information for rev 46

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 {
46 office 26 SerialPort.Write($"{Name}{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  
15 office 40 var radioBank = int.Parse(match.Result("${radioBank}"));
41 var Frequency = int.Parse(match.Result("${frequency}"));
42 var clarifierDirection = char.Parse(match.Result("${clarifierDirection}"));
43 var clarifierOffset = int.Parse(match.Result("${clarifierOffset}"));
44 var clar = int.Parse(match.Result("${clar}")) == 0 ? false : true;
45 var radioMode = char.Parse(match.Result("${mode}"));
46 var storage = match.Result("${storage}");
46 office 47 var ctcss = match.Result("${ctcssMode}");
15 office 48 var phase = match.Result("${phase}");
49  
3 office 50 var information = new Information
51 {
15 office 52 RadioBank = radioBank,
53 Frequency = Frequency,
54 ClarifierDirection = clarifierDirection,
55 ClarifierOffset = clarifierOffset,
56 Clar = clar,
43 office 57 RadioMode = new RadioMode(radioMode),
15 office 58 Storage = storage,
46 office 59 Ctcss = new Ctcss(ctcss),
60 Phase = new Phase(phase)
3 office 61 };
11 office 62  
3 office 63 return information;
64 }
65 }
66 }