public static RspRsiInfo ChangeRsi(BaseDevice device, int rsiOld, int rsiNew, int mnp) { RspRsiInfo result = new RspRsiInfo(); if (device.TwiKfdtoolDevice.ComPort == string.Empty) { throw new ArgumentException("No device selected"); } AdapterProtocol ap = null; try { ap = new AdapterProtocol(device.TwiKfdtoolDevice.ComPort); ap.Open(); ap.Clear(); ManualRekeyApplication mra = new ManualRekeyApplication(ap); result = mra.ChangeRsi(rsiOld, rsiNew, mnp); } catch (Exception) { throw; } finally { try { if (ap != null) { ap.Close(); } } catch (System.IO.IOException ex) { Logger.Warn("could not close serial port: {0}", ex.Message); } } return(result); }
public static RspRsiInfo LoadConfig(string port, int kmfRsi, int mnp) { RspRsiInfo result = new RspRsiInfo(); if (port == string.Empty) { throw new ArgumentException("port empty"); } AdapterProtocol ap = null; try { ap = new AdapterProtocol(port); ap.Open(); ap.Clear(); ManualRekeyApplication mra = new ManualRekeyApplication(ap); result = mra.LoadConfig(kmfRsi, mnp); } catch (Exception) { throw; } finally { try { if (ap != null) { ap.Close(); } } catch (System.IO.IOException ex) { Logger.Warn("could not close serial port: {0}", ex.Message); } } return(result); }