VAGSuite.EDC15P_EEPROM.UpdateFile C# (CSharp) Метод

UpdateFile() публичный Метод

public UpdateFile ( string filename ) : void
filename string
Результат void
        public void UpdateFile(string filename)
        {
            EEPRomBytes = File.ReadAllBytes(filename);
            // write key in bytes
            byte khb = Convert.ToByte(key / 256);
            byte klb = Convert.ToByte( key - (Convert.ToInt32(khb) * 256) );
            EEPRomBytes[0x160] = klb;
            EEPRomBytes[0x161] = khb;
            // write mileage in bytes
            // convert to int32

            // write immo active bytes 0x1B0 AND 0x1DE
            byte activeByte = 0x60;
            if(_immoActive) activeByte = 0x73;
            EEPRomBytes[0x1B0] = activeByte;
            EEPRomBytes[0x1DE] = activeByte;

            // write VIN
            if (Vin.Length == 17)
            {
                byte[] _vinbytes = System.Text.ASCIIEncoding.ASCII.GetBytes(_vin);
                int start = 0x140;
                for (int i = 0; i < _vinbytes.Length; i++)
                {
                    EEPRomBytes[start++] = _vinbytes[i];
                }
                start = 0x172;
                for (int i = 0; i < _vinbytes.Length; i++)
                {
                    EEPRomBytes[start++] = _vinbytes[i];
                }
            }
            // write IMMO code
            if (_immo.Length == 14)
            {
                byte[] _immobytes = System.Text.ASCIIEncoding.ASCII.GetBytes(_immo);
                int start = 0x131;
                for (int i = 0; i < _immobytes.Length; i++)
                {
                    EEPRomBytes[start++] = _immobytes[i];
                }
                start = 0x163;
                for (int i = 0; i < _immobytes.Length; i++)
                {
                    EEPRomBytes[start++] = _immobytes[i];
                }
            }
            File.WriteAllBytes(filename, EEPRomBytes);
        }

Usage Example

Пример #1
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     eeprom.Vin = textEdit3.Text;
     eeprom.Immo = textEdit1.Text;
     eeprom.ImmoActive = checkEdit1.Checked;
     eeprom.Key = Convert.ToInt32(textEdit4.Text);
     eeprom.UpdateFile(_filename);
     DialogResult = DialogResult.OK;
     this.Close();
 }