예제 #1
0
        public SerialParameters LoadParameters()
        {
            var param = new SerialParameters();

            try
            {
                using (var reader = new StreamReader("Parameters.xml"))
                {
                    var xs = new XmlSerializer(typeof(SerialParameters));
                    param = (SerialParameters)xs.Deserialize(reader);
                }
            }
            catch (Exception ex)
            {
                param = new SerialParameters()
                {
                    BaudRate  = 115200,
                    DataBits  = 8,
                    Parity    = Parity.None,
                    Handshake = Handshake.None,
                    StopBits  = StopBits.One
                };
            }
            return(param);
        }
예제 #2
0
 public void SaveParameters(SerialParameters param)
 {
     using (var writer = new StreamWriter("Parameters.xml"))
     {
         var xs = new XmlSerializer(typeof(SerialParameters));
         xs.Serialize(writer, param);
     }
 }