public static string ReadModel(BaseDevice device) { string model = string.Empty; 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(); byte mod = ap.ReadModelId(); if (mod == 0x00) { model = "NOT SET"; } else if (mod == 0x01) { model = "KFD100"; } else if (mod == 0x02) { model = "KFD-AVR"; } else { model = "UNKNOWN"; } } 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(model); }