HamBook – Diff between revs 46 and 54
?pathlinks?
Rev 46 | Rev 54 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | using HamBook.Radios.Generic; |
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; |
- | ||
11 | using RJCP.IO.Ports; |
2 | using RJCP.IO.Ports; |
|
- | 3 | using static HamBook.Radios.Yaesu.FT_891.Constants; |
||
Line 12... | Line 4... | |||
12 | |
4 | |
|
13 | namespace HamBook.Radios.Yaesu.FT_891.CAT |
5 | namespace HamBook.Radios.Yaesu.FT_891.CAT |
|
14 | { |
6 | { |
|
15 | [Radio("Yaesu FT-891")] |
7 | [Radio("Yaesu FT-891")] |
|
16 | public class IF : Generic.CAT.IF |
8 | public class If : Generic.CAT.If |
|
17 | { |
- | ||
18 | public override CatLength CatLength => new CatLength { Answer = 28, Read = 3 }; |
- | ||
19 | |
9 | { |
|
20 | public IF(SerialPortStream serialPort) : base(serialPort) |
10 | public If(SerialPortStream serialPort) : base(serialPort) |
|
21 | { |
11 | { |
|
Line -... | Line 12... | |||
- | 12 | } |
||
- | 13 | |
||
22 | } |
14 | public override CatLength CatLength => new CatLength { Answer = 28, Read = 3 }; |
|
23 | |
15 | |
|
24 | public override Information Read() |
16 | public override Information Read() |
|
25 | { |
17 | { |
|
26 | SerialPort.Write($"{Name}{Constants.EOT}"); |
18 | SerialPort.Write($"{Name}{Eot}"); |
|
27 | var buffer = new byte[CatLength.Answer]; |
- | ||
28 | if (SerialPort.Read(buffer, 0, CatLength.Answer) != CatLength.Answer) |
19 | var buffer = new byte[CatLength.Answer]; |
|
29 | { |
- | ||
Line 30... | Line 20... | |||
30 | throw new UnexpectedRadioResponseException(Name, buffer); |
20 | if (SerialPort.Read(buffer, 0, CatLength.Answer) != CatLength.Answer) |
|
31 | } |
21 | throw new UnexpectedRadioResponseException(Name, buffer); |
|
32 | |
- | ||
33 | var answer = Constants.Encoding.GetString(buffer); |
- | ||
34 | var match = InformationRegex.Match(answer); |
22 | |
|
35 | if (!match.Success) |
- | ||
Line 36... | Line 23... | |||
36 | { |
23 | var answer = Encoding.GetString(buffer); |
|
37 | throw new UnmatchedRadioResponseException(Name, answer); |
24 | var match = InformationRegex.Match(answer); |
|
38 | } |
25 | if (!match.Success) throw new UnmatchedRadioResponseException(Name, answer); |
|
39 | |
26 | |
|
40 | var radioBank = int.Parse(match.Result("${radioBank}")); |
27 | var radioBank = int.Parse(match.Result("${radioBank}")); |
|
41 | var Frequency = int.Parse(match.Result("${frequency}")); |
28 | var frequency = int.Parse(match.Result("${frequency}")); |
|
42 | var clarifierDirection = char.Parse(match.Result("${clarifierDirection}")); |
29 | var clarifierDirection = char.Parse(match.Result("${clarifierDirection}")); |
|
Line 48... | Line 35... | |||
48 | var phase = match.Result("${phase}"); |
35 | var phase = match.Result("${phase}"); |
|
Line 49... | Line 36... | |||
49 | |
36 | |
|
50 | var information = new Information |
37 | var information = new Information |
|
51 | { |
38 | { |
|
52 | RadioBank = radioBank, |
39 | RadioBank = radioBank, |
|
53 | Frequency = Frequency, |
40 | Frequency = frequency, |
|
54 | ClarifierDirection = clarifierDirection, |
41 | ClarifierDirection = clarifierDirection, |
|
55 | ClarifierOffset = clarifierOffset, |
42 | ClarifierOffset = clarifierOffset, |
|
56 | Clar = clar, |
43 | Clar = clar, |
|
57 | RadioMode = new RadioMode(radioMode), |
44 | RadioMode = new RadioMode(radioMode), |
|
Line 61... | Line 48... | |||
61 | }; |
48 | }; |
|
Line 62... | Line 49... | |||
62 | |
49 | |
|
63 | return information; |
50 | return information; |
|
64 | } |
51 | } |
|
65 | } |
52 | } |
|
66 | } |
53 | } |