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