Ejemplo n.º 1
0
        private static void WriteConfig(ushort degreesCorrection)
        {
            byte[]     buffer = new byte[ConfigFile.ConfigLength];
            FileStream fs     = new FileStream(ConfigFile.ConfigPath, FileMode.OpenOrCreate);

            ConfigFileBuffer configFile = new ConfigFileBuffer();

            configFile.ConfigVersion     = 1;
            configFile.DegreesCorrection = degreesCorrection;

            Microsoft.SPOT.Hardware.Utility.InsertValueIntoArray(buffer, 0, 2, configFile.ConfigVersion);
            Microsoft.SPOT.Hardware.Utility.InsertValueIntoArray(buffer, 2, 2, configFile.DegreesCorrection);

            fs.Write(buffer, 0, ConfigLength);
        }
Ejemplo n.º 2
0
        private static ConfigFileBuffer ReadConfig()
        {
            byte[]     buffer     = new byte[ConfigFile.ConfigLength];
            FileStream fs         = new FileStream(ConfigFile.ConfigPath, FileMode.OpenOrCreate);
            int        lengthRead = fs.Read(buffer, 0, buffer.Length);

            ConfigFileBuffer configFile = new ConfigFileBuffer();

            if (lengthRead == ConfigLength)
            {
                configFile.ConfigVersion     = (ushort)Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray(buffer, 0, 2);
                configFile.DegreesCorrection = (ushort)Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray(buffer, 2, 2);
            }

            if (lengthRead != ConfigLength || configFile.ConfigVersion != 1)
            {
                configFile = new ConfigFileBuffer();
                configFile.ConfigVersion     = 1;
                configFile.DegreesCorrection = 0;
            }

            return(configFile);
        }