HamBook – Diff between revs 9 and 11

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 9 Rev 11
Line 14... Line 14...
14 { 14 {
15 [Radio("Yaesu FT-891")] 15 [Radio("Yaesu FT-891")]
16 public class IF : Generic.CAT.IF 16 public class IF : Generic.CAT.IF
17 { 17 {
18 public override CatLength CatLength => new CatLength { Answer = 28, Read = 3 }; 18 public override CatLength CatLength => new CatLength { Answer = 28, Read = 3 };
-   19  
19 public IF(SerialPortStream serialPort) : base(serialPort) 20 public IF(SerialPortStream serialPort) : base(serialPort)
20 { 21 {
21 } 22 }
Line 22... Line 23...
22   23  
23 public override Information Read() 24 public override Information Read()
24 { 25 {
-   26 SerialPort.Write($"{Name}{Generic.Constants.EOT}");
-   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 }
25 SerialPort.Write($"{Name}{Generic.Constants.EOT}"); 32  
26 var result = SerialPort.ReadTo($"{Generic.Constants.EOT}"); 33 var answer = Constants.Encoding.GetString(buffer);
-   34 var match = InformationRegex.Match(answer);
-   35 if (!match.Success)
-   36 {
-   37 throw new UnmatchedRadioResponseException(Name, answer);
Line 27... Line 38...
27 var match = InformationRegex.Match(result); 38 }
28   39  
29 var information = new Information 40 var information = new Information
30 { 41 {
Line 36... Line 47...
36 RadioMode = char.Parse(match.Result("${mode}")), 47 RadioMode = char.Parse(match.Result("${mode}")),
37 Storage = (RadioStorage)int.Parse(match.Result("${storage}")), 48 Storage = (RadioStorage)int.Parse(match.Result("${storage}")),
38 CtcssMode = (CtcssMode)int.Parse(match.Result("${ctcssMode}")), 49 CtcssMode = (CtcssMode)int.Parse(match.Result("${ctcssMode}")),
39 Phase = (RadioPhase)int.Parse(match.Result("${phase}")) 50 Phase = (RadioPhase)int.Parse(match.Result("${phase}"))
40 }; 51 };
41 52  
42 return information; 53 return information;
43 } 54 }
44 } 55 }
45 } 56 }