HamBook – Diff between revs 54 and 58
?pathlinks?
Rev 54 | Rev 58 | |||
---|---|---|---|---|
Line 53... | Line 53... | |||
53 | type.GetCustomAttribute<RadioAttribute>() != null && |
53 | type.GetCustomAttribute<RadioAttribute>() != null && |
|
54 | type.GetCustomAttribute<RadioAttribute>().Radio == radio)) |
54 | type.GetCustomAttribute<RadioAttribute>().Radio == radio)) |
|
55 | try |
55 | try |
|
56 | { |
56 | { |
|
57 | var catCommand = (Cat)type |
57 | var catCommand = (Cat)type |
|
58 | .GetConstructor(new[] { typeof(SerialPortStream) }) |
58 | .GetConstructor(new[] { typeof(SerialPortStream) })?.Invoke(new object[] { _serialPort }); |
|
59 | .Invoke(new[] { _serialPort }); |
- | ||
Line 60... | Line 59... | |||
60 | |
59 | |
|
Line 61... | Line 60... | |||
61 | if (catCommand == null) throw new ArgumentException(Resources.Could_not_create_assembly); |
60 | if (catCommand == null) throw new ArgumentException(Resources.Could_not_create_assembly); |
|
62 | |
61 | |
|
Line 113... | Line 112... | |||
113 | } |
112 | } |
|
Line 114... | Line 113... | |||
114 | |
113 | |
|
115 | _catCommands.Clear(); |
114 | _catCommands.Clear(); |
|
Line 116... | Line 115... | |||
116 | } |
115 | } |
|
117 | |
116 | |
|
118 | public T CatParse<T>(string command, object[] param) |
117 | public bool CatParse<T>(string command, object[] param, out T output) |
|
119 | { |
- | ||
120 | if (_catCommands.TryGetValue(command, out var catCommand)) |
- | ||
121 | { |
118 | { |
|
Line -... | Line 119... | |||
- | 119 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
- | 120 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
||
- | 121 | |
||
122 | var methodInfo = catCommand.GetType().GetMethod("Parse"); |
122 | var methodInfo = catCommand.GetType().GetMethod("Parse"); |
|
- | 123 | if (methodInfo == null) |
||
- | 124 | { |
||
- | 125 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Parse"); |
||
- | 126 | |
||
- | 127 | } |
||
- | 128 | |
||
- | 129 | output = default; |
||
- | 130 | try |
||
- | 131 | { |
||
- | 132 | output = (T)methodInfo.Invoke(catCommand, param); |
||
- | 133 | } |
||
123 | if (methodInfo != null) return (T)methodInfo.Invoke(catCommand, param); |
134 | catch |
|
Line 124... | Line 135... | |||
124 | |
135 | { |
|
125 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Parse"); |
136 | return false; |
|
Line 126... | Line 137... | |||
126 | } |
137 | } |
|
127 | |
138 | |
|
128 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
139 | return true; |
|
Line 129... | Line 140... | |||
129 | } |
140 | } |
|
130 | |
141 | |
|
131 | public T CatGetDefault<T>(string command, object[] param) |
142 | public T CatGetDefault<T>(string command, object[] param) |
|
Line 132... | Line -... | |||
132 | { |
- | ||
133 | _semaphoreSlim.Wait(); |
- | ||
134 | |
143 | { |
|
135 | try |
- | ||
136 | { |
- | ||
137 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
138 | |
- | ||
139 | try |
- | ||
140 | { |
- | ||
141 | if (_catCommands.TryGetValue(command, out var catCommand)) |
144 | _semaphoreSlim.Wait(); |
|
- | 145 | |
||
- | 146 | try |
||
142 | { |
147 | { |
|
143 | var methodInfo = catCommand.GetType().GetMethod("GetDefault"); |
148 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
144 | if (methodInfo != null) return (T)methodInfo.Invoke(catCommand, param); |
- | ||
145 | } |
149 | |
|
146 | } |
150 | if (_catCommands.TryGetValue(command, out var catCommand)) |
|
147 | finally |
151 | { |
|
148 | { |
152 | var methodInfo = catCommand.GetType().GetMethod("GetDefault"); |
|
149 | if (_serialPort.IsOpen) |
153 | |
|
150 | { |
154 | if (methodInfo != null) |
|
- | 155 | { |
||
- | 156 | return (T)methodInfo.Invoke(catCommand, param); |
||
- | 157 | } |
||
- | 158 | } |
||
- | 159 | } |
||
- | 160 | finally |
||
151 | _serialPort.Flush(); |
161 | { |
|
152 | _serialPort.Close(); |
162 | if (_serialPort.IsOpen) |
|
Line 153... | Line 163... | |||
153 | } |
163 | { |
|
154 | } |
164 | _serialPort.Flush(); |
|
Line 155... | Line 165... | |||
155 | } |
165 | _serialPort.Close(); |
|
156 | finally |
166 | } |
|
157 | { |
167 | |
|
158 | _semaphoreSlim.Release(); |
- | ||
159 | } |
168 | _semaphoreSlim.Release(); |
|
160 | |
169 | } |
|
161 | return default; |
170 | |
|
Line 162... | Line -... | |||
162 | } |
- | ||
163 | |
- | ||
164 | public void CatSet<T>(string command, object[] param) |
171 | return default; |
|
165 | { |
- | ||
166 | _semaphoreSlim.Wait(); |
- | ||
167 | |
- | ||
168 | try |
- | ||
169 | { |
172 | } |
|
170 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
171 | |
- | ||
172 | try |
- | ||
Line -... | Line 173... | |||
- | 173 | |
||
173 | { |
174 | public void CatSet(string command, object[] param) |
|
174 | if (_catCommands.TryGetValue(command, out var catCommand)) |
- | ||
Line 175... | Line -... | |||
175 | { |
- | ||
176 | var methodInfo = catCommand.GetType().GetMethod("Set"); |
- | ||
177 | if (methodInfo != null) |
- | ||
178 | { |
- | ||
179 | methodInfo.Invoke(catCommand, param); |
175 | { |
|
180 | |
- | ||
181 | return; |
- | ||
182 | } |
- | ||
183 | |
- | ||
184 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Set"); |
- | ||
185 | } |
176 | _semaphoreSlim.Wait(); |
|
186 | |
177 | try |
|
187 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
178 | { |
|
- | 179 | if (!_serialPort.IsOpen) _serialPort.Open(); |
||
- | 180 | |
||
- | 181 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
- | 182 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
||
- | 183 | |
||
- | 184 | var methodInfo = catCommand.GetType().GetMethod("Set") ?? |
||
188 | } |
185 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Set"); |
|
189 | finally |
186 | |
|
190 | { |
187 | methodInfo.Invoke(catCommand, param); |
|
Line 191... | Line 188... | |||
191 | if (_serialPort.IsOpen) |
188 | } |
|
Line 207... | Line 204... | |||
207 | |
204 | |
|
208 | try |
205 | try |
|
209 | { |
206 | { |
|
Line 210... | Line -... | |||
210 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
211 | |
- | ||
212 | try |
207 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
213 | { |
- | ||
214 | if (_catCommands.TryGetValue(command, out var catCommand)) |
- | ||
215 | { |
- | ||
216 | var methodInfo = catCommand.GetType().GetMethod("SetAsync"); |
- | ||
217 | if (methodInfo != null) |
- | ||
218 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() != null) |
- | ||
219 | { |
- | ||
220 | var parameters = new List<object>(); |
208 | |
|
Line -... | Line 209... | |||
- | 209 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
221 | parameters.AddRange(param); |
210 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
|
Line 222... | Line 211... | |||
222 | parameters.Add(cancellationToken); |
211 | |
|
223 | |
212 | var methodInfo = catCommand.GetType().GetMethod("SetAsync") ?? |
|
Line 224... | Line 213... | |||
224 | var result = await (Task<TU>)methodInfo.Invoke(catCommand, parameters.ToArray()); |
213 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "SetAsync"); |
|
225 | |
214 | |
|
- | 215 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() == null) |
||
Line 226... | Line 216... | |||
226 | return result; |
216 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "SetAsync"); |
|
227 | } |
- | ||
- | 217 | |
||
228 | |
218 | var parameters = new List<object>(); |
|
229 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "SetAsync"); |
- | ||
230 | } |
- | ||
231 | |
- | ||
232 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
- | ||
233 | } |
- | ||
234 | finally |
- | ||
235 | { |
- | ||
236 | if (_serialPort.IsOpen) |
219 | parameters.AddRange(param); |
|
237 | { |
220 | parameters.Add(cancellationToken); |
|
238 | await _serialPort.FlushAsync(cancellationToken); |
221 | |
|
- | 222 | var result = await (Task<TU>)methodInfo.Invoke(catCommand, parameters.ToArray()); |
||
- | 223 | |
||
- | 224 | return result; |
||
- | 225 | } |
||
- | 226 | finally |
||
- | 227 | { |
||
239 | _serialPort.Close(); |
228 | if (_serialPort.IsOpen) |
|
240 | } |
229 | { |
|
241 | } |
230 | await _serialPort.FlushAsync(cancellationToken); |
|
Line 242... | Line 231... | |||
242 | } |
231 | _serialPort.Close(); |
|
Line 252... | Line 241... | |||
252 | |
241 | |
|
253 | try |
242 | try |
|
254 | { |
243 | { |
|
Line 255... | Line -... | |||
255 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
256 | |
- | ||
257 | try |
244 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
258 | { |
- | ||
259 | if (_catCommands.TryGetValue(command, out var catCommand)) |
- | ||
260 | { |
- | ||
261 | var methodInfo = catCommand.GetType().GetMethod("Write"); |
- | ||
262 | if (methodInfo != null) |
245 | |
|
263 | { |
- | ||
264 | methodInfo.Invoke(catCommand, param); |
- | ||
265 | |
- | ||
Line -... | Line 246... | |||
- | 246 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
266 | return; |
247 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
|
267 | } |
- | ||
Line 268... | Line -... | |||
268 | |
- | ||
269 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Write"); |
- | ||
270 | } |
- | ||
271 | |
- | ||
272 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
248 | |
|
273 | } |
- | ||
274 | finally |
249 | var methodInfo = catCommand.GetType().GetMethod("Write") ?? |
|
275 | { |
250 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Write"); |
|
276 | if (_serialPort.IsOpen) _serialPort.Flush(); |
251 | |
|
- | 252 | methodInfo.Invoke(catCommand, param); |
||
- | 253 | } |
||
- | 254 | finally |
||
- | 255 | { |
||
- | 256 | if (_serialPort.IsOpen) |
||
- | 257 | { |
||
277 | } |
258 | _serialPort.Flush(); |
|
278 | } |
259 | _serialPort.Close(); |
|
279 | finally |
260 | } |
|
Line 280... | Line 261... | |||
280 | { |
261 | |
|
Line 288... | Line 269... | |||
288 | |
269 | |
|
289 | try |
270 | try |
|
290 | { |
271 | { |
|
Line 291... | Line -... | |||
291 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
292 | |
- | ||
293 | try |
272 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
294 | { |
- | ||
295 | if (_catCommands.TryGetValue(command, out var catCommand)) |
273 | |
|
296 | { |
- | ||
297 | var methodInfo = catCommand.GetType().GetMethod("WriteAsync"); |
- | ||
298 | if (methodInfo != null) |
- | ||
299 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() != null) |
- | ||
300 | { |
- | ||
301 | var parameters = new List<object>(); |
- | ||
Line -... | Line 274... | |||
- | 274 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
302 | parameters.AddRange(param); |
275 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
|
Line 303... | Line 276... | |||
303 | parameters.Add(cancellationToken); |
276 | |
|
304 | |
277 | var methodInfo = catCommand.GetType().GetMethod("WriteAsync") ?? |
|
Line 305... | Line 278... | |||
305 | await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); |
278 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
|
306 | |
279 | |
|
- | 280 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() == null) |
||
Line 307... | Line 281... | |||
307 | return; |
281 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
|
308 | } |
282 | |
|
309 | |
283 | var parameters = new List<object>(); |
|
- | 284 | parameters.AddRange(param); |
||
- | 285 | parameters.Add(cancellationToken); |
||
310 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
286 | |
|
311 | } |
287 | await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); |
|
- | 288 | } |
||
312 | |
289 | finally |
|
- | 290 | { |
||
- | 291 | if (_serialPort.IsOpen) |
||
- | 292 | { |
||
- | 293 | await _serialPort.FlushAsync(cancellationToken); |
||
- | 294 | _serialPort.Close(); |
||
- | 295 | } |
||
- | 296 | |
||
- | 297 | _semaphoreSlim.Release(); |
||
- | 298 | } |
||
- | 299 | } |
||
- | 300 | |
||
- | 301 | public async Task CatWriteAsyncManual<T>(string command, object[] param, CancellationToken cancellationToken) |
||
- | 302 | { |
||
- | 303 | await _semaphoreSlim.WaitAsync(cancellationToken); |
||
- | 304 | |
||
- | 305 | try |
||
- | 306 | { |
||
- | 307 | if (!_serialPort.IsOpen) _serialPort.Open(); |
||
- | 308 | |
||
- | 309 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
- | 310 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
||
- | 311 | |
||
- | 312 | var methodInfo = catCommand.GetType().GetMethod("WriteAsync") ?? |
||
- | 313 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
||
- | 314 | |
||
- | 315 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() == null) |
||
- | 316 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
||
313 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
317 | |
|
314 | } |
318 | var parameters = new List<object>(); |
|
315 | finally |
319 | parameters.AddRange(param); |
|
- | 320 | parameters.Add(cancellationToken); |
||
- | 321 | |
||
- | 322 | await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); |
||
- | 323 | } |
||
- | 324 | finally |
||
316 | { |
325 | { |
|
317 | if (_serialPort.IsOpen) await _serialPort.FlushAsync(cancellationToken); |
326 | if (_serialPort.IsOpen) |
|
318 | } |
327 | { |
|
Line 319... | Line 328... | |||
319 | } |
328 | await _serialPort.FlushAsync(cancellationToken); |
|
Line 329... | Line 338... | |||
329 | |
338 | |
|
330 | try |
339 | try |
|
331 | { |
340 | { |
|
Line 332... | Line -... | |||
332 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
333 | |
- | ||
334 | try |
341 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
335 | { |
- | ||
336 | if (_catCommands.TryGetValue(command, out var catCommand)) |
342 | |
|
337 | { |
- | ||
338 | var methodInfo = catCommand.GetType().GetMethod("WriteAsync"); |
- | ||
339 | if (methodInfo != null) |
- | ||
340 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() != null) |
- | ||
341 | { |
- | ||
342 | var parameters = new List<object>(); |
- | ||
Line -... | Line 343... | |||
- | 343 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
||
343 | parameters.AddRange(param); |
344 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
|
Line 344... | Line 345... | |||
344 | parameters.Add(cancellationToken); |
345 | |
|
345 | |
346 | var methodInfo = catCommand.GetType().GetMethod("WriteAsync") ?? |
|
Line 346... | Line 347... | |||
346 | await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); |
347 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
|
347 | |
348 | |
|
- | 349 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() == null) |
||
Line 348... | Line 350... | |||
348 | return; |
350 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
|
349 | } |
- | ||
350 | |
- | ||
351 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "WriteAsync"); |
- | ||
352 | } |
- | ||
353 | |
- | ||
354 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
351 | |
|
355 | } |
352 | var parameters = new List<object>(); |
|
356 | finally |
353 | parameters.AddRange(param); |
|
- | 354 | parameters.Add(cancellationToken); |
||
- | 355 | |
||
- | 356 | await (Task)methodInfo.Invoke(catCommand, parameters.ToArray()); |
||
- | 357 | } |
||
- | 358 | finally |
||
- | 359 | { |
||
357 | { |
360 | if (_serialPort.IsOpen) |
|
358 | if (_serialPort.IsOpen) await _serialPort.FlushAsync(cancellationToken); |
361 | { |
|
359 | } |
362 | await _serialPort.FlushAsync(cancellationToken); |
|
Line 360... | Line 363... | |||
360 | } |
363 | _serialPort.Close(); |
|
Line 370... | Line 373... | |||
370 | |
373 | |
|
371 | try |
374 | try |
|
372 | { |
375 | { |
|
Line 373... | Line -... | |||
373 | if (!_serialPort.IsOpen) _serialPort.Open(); |
- | ||
374 | |
- | ||
375 | try |
376 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
376 | { |
- | ||
377 | if (_catCommands.TryGetValue(command, out var catCommand)) |
- | ||
378 | { |
377 | |
|
Line 379... | Line 378... | |||
379 | var methodInfo = catCommand.GetType().GetMethod("Read"); |
378 | if (!_catCommands.TryGetValue(command, out var catCommand)) |
|
380 | if (methodInfo != null) return (T)methodInfo.Invoke(catCommand, param); |
379 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
|
Line 381... | Line 380... | |||
381 | |
380 | |
|
382 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Read"); |
- | ||
383 | } |
- | ||
384 | |
- | ||
385 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
- | ||
386 | } |
- | ||
387 | finally |
- | ||
388 | { |
- | ||
389 | if (_serialPort.IsOpen) |
- | ||
390 | { |
- | ||
391 | _serialPort.Flush(); |
381 | var methodInfo = catCommand.GetType().GetMethod("Read"); |
|
392 | _serialPort.Close(); |
382 | if (methodInfo != null) return (T)methodInfo.Invoke(catCommand, param); |
|
393 | } |
383 | |
|
- | 384 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "Read"); |
||
- | 385 | } |
||
- | 386 | finally |
||
- | 387 | { |
||
- | 388 | if (_serialPort.IsOpen) |
||
- | 389 | { |
||
394 | } |
390 | _serialPort.Flush(); |
|
395 | } |
391 | _serialPort.Close(); |
|
396 | finally |
392 | } |
|
Line 397... | Line 393... | |||
397 | { |
393 | |
|
Line 405... | Line 401... | |||
405 | |
401 | |
|
406 | try |
402 | try |
|
407 | { |
403 | { |
|
Line 408... | Line 404... | |||
408 | if (!_serialPort.IsOpen) _serialPort.Open(); |
404 | if (!_serialPort.IsOpen) _serialPort.Open(); |
|
409 | |
405 | |
|
410 | try |
- | ||
411 | { |
- | ||
412 | if (_catCommands.TryGetValue(command, out var catCommand)) |
406 | if (_catCommands.TryGetValue(command, out var catCommand)) |
|
413 | { |
- | ||
414 | var methodInfo = catCommand.GetType().GetMethod("ReadAsync"); |
407 | { |
|
415 | if (methodInfo != null) |
- | ||
416 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() != null) |
- | ||
417 | { |
- | ||
418 | var parameters = new List<object>(); |
- | ||
Line -... | Line 408... | |||
- | 408 | var methodInfo = catCommand.GetType().GetMethod("ReadAsync") ?? |
||
419 | parameters.AddRange(param); |
409 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "ReadAsync"); |
|
Line 420... | Line 410... | |||
420 | parameters.Add(cancellationToken); |
410 | |
|
421 | |
411 | if (methodInfo.GetCustomAttribute<AsyncStateMachineAttribute>() == null) |
|
- | 412 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "ReadAsync"); |
||
Line 422... | Line 413... | |||
422 | var result = await (Task<T>)methodInfo.Invoke(catCommand, parameters.ToArray()); |
413 | |
|
- | 414 | var parameters = new List<object>(); |
||
423 | |
415 | parameters.AddRange(param); |
|
Line 424... | Line -... | |||
424 | return result; |
- | ||
425 | } |
- | ||
426 | |
- | ||
427 | throw new CatCommandException(Resources.CAT_command_method_not_found, command, "ReadAsync"); |
- | ||
428 | } |
- | ||
429 | |
- | ||
430 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
- | ||
431 | } |
- | ||
432 | finally |
- | ||
433 | { |
416 | parameters.Add(cancellationToken); |
|
- | 417 | |
||
- | 418 | var result = await (Task<T>)methodInfo.Invoke(catCommand, parameters.ToArray()); |
||
434 | if (_serialPort.IsOpen) |
419 | |
|
435 | { |
420 | return result; |
|
436 | await _serialPort.FlushAsync(cancellationToken); |
421 | |
|
- | 422 | } |
||
- | 423 | |
||
- | 424 | throw new CatCommandException(Resources.CAT_command_not_found, command); |
||
- | 425 | } |
||
- | 426 | finally |
||
- | 427 | { |
||
437 | _serialPort.Close(); |
428 | if (_serialPort.IsOpen) |
|
438 | } |
429 | { |
|
439 | } |
430 | await _serialPort.FlushAsync(cancellationToken); |
|
440 | } |
431 | _serialPort.Close(); |
|
441 | finally |
432 | } |
|
442 | { |
433 | |