|
7 | 7 | using System.Collections.Generic; |
8 | 8 | using System.IO; |
9 | 9 | using System.Linq; |
| 10 | +using System.Text; |
10 | 11 | using System.Text.RegularExpressions; |
11 | 12 |
|
12 | 13 | namespace nanoFramework.Tools.FirmwareFlasher |
@@ -89,20 +90,24 @@ public JLinkDevice(string probeId = null) |
89 | 90 | } |
90 | 91 |
|
91 | 92 | // parse the output to fill in the details |
92 | | - var match = Regex.Match(cliOutput, @"(Device "")(?<deviceid>\w*)("" selected\.)|(Firmware: )(?<firmware>.*)", RegexOptions.Multiline); |
| 93 | + var match = Regex.Match(cliOutput, "(Firmware: )(?<firmware>.*)$", RegexOptions.Multiline); |
93 | 94 | if (match.Success) |
94 | 95 | { |
95 | | - // grab details |
96 | | - DeviceId = match.Groups["deviceid"].ToString().Trim(); |
97 | | - |
98 | | - if (match.Groups["firmware"] != null) |
| 96 | + if (match.Groups["firmware"].Captures.Count > 0) |
99 | 97 | { |
100 | 98 | Firmare = match.Groups["firmware"].ToString().Trim(); |
101 | 99 | } |
102 | 100 | } |
103 | 101 |
|
| 102 | + match = Regex.Match(cliOutput, @"(Device "")(?<deviceid>.*)("" selected.)", RegexOptions.Multiline); |
| 103 | + if (match.Success) |
| 104 | + { |
| 105 | + // grab details |
| 106 | + DeviceId = match.Groups["deviceid"].ToString().Trim(); |
| 107 | + } |
| 108 | + |
104 | 109 | match = Regex.Match(cliOutput, @"(Hardware version: )(?<hardware>.*)", RegexOptions.Multiline); |
105 | | - if (match.Success && match.Groups["hardware"] != null) |
| 110 | + if (match.Success && match.Groups["hardware"].Captures.Count > 0) |
106 | 111 | { |
107 | 112 | Hardware = match.Groups["hardware"].ToString().Trim(); |
108 | 113 | } |
@@ -175,5 +180,18 @@ public ExitCodes FlashHexFiles(IList<string> files) |
175 | 180 | files, |
176 | 181 | ProbeId); |
177 | 182 | } |
| 183 | + |
| 184 | + /// <inheritdoc/> |
| 185 | + public override string ToString() |
| 186 | + { |
| 187 | + StringBuilder deviceInfo = new(); |
| 188 | + |
| 189 | + deviceInfo.AppendLine($"JLink firmware: {Firmare}"); |
| 190 | + deviceInfo.AppendLine($"JLink hardware: {Hardware}"); |
| 191 | + deviceInfo.AppendLine($"CPU: {DeviceCPU}"); |
| 192 | + deviceInfo.AppendLine($"Device ID: {DeviceId}"); |
| 193 | + |
| 194 | + return deviceInfo.ToString(); |
| 195 | + } |
178 | 196 | } |
179 | 197 | } |
0 commit comments