Exemplo n.º 1
0
        /// <summary>
        /// Start uploading configuration file(s) to ecu
        /// </summary>
        /// <returns>True if file upload thread is started successfully</returns>
        public bool UploadConfig(string FileName)
        {
            HJS.BlockFile   _file = new HJS.BlockFile();
            HJS.ReturnValue ret   = _file.Open(HJS.BlockFile.FileIdentifier.ParameterSet, FileName);
            if (ret == HJS.ReturnValue.NoError)
            {
                HJS.Block _cfg;
                HJS.Block _kf;
                HJS.Block _lng1;
                HJS.Block _lng2;
                HJS.Block _lng3;
                HJS.Block _lng4;
                HJS.Block _lng5 = null;
                HJS.Block _lng6 = null;
                HJS.Block _lng7 = null;
                HJS.Block _lng8 = null;
                ret = _file.GetBlock(out _cfg, HJS.Block.BlockId.IdKonfig, false);
                if (ret == HJS.ReturnValue.NoError)
                {
                    CurrentConfigVersion = _cfg.GetCfgVersion();
                    if (mECU.GetCompatibility() != _cfg.Version)
                    {
                        // Config does not match software on ecu
                        tellStatus(String.Format("Konfiguration nicht kompatibel zu Software ({0} benötigt!)", mECU.GetCompatibility()));
                        return(false);
                    }
                    else
                    {
                        ret = _file.GetBlock(out _kf, HJS.Block.BlockId.IdKennfld, false);
                    }
                    if (ret == HJS.ReturnValue.NoError)
                    {
                        ret = _file.GetBlock(out _lng1, HJS.Block.BlockId.IdLngDE, false);
                        if (ret == HJS.ReturnValue.NoError)
                        {
                            LastCrcLng1 = _lng1.Checksum;
                            ret         = _file.GetBlock(out _lng2, HJS.Block.BlockId.IdLngEN, false);
                            if (ret == HJS.ReturnValue.NoError)
                            {
                                LastCrcLng2 = _lng2.Checksum;
                                ret         = _file.GetBlock(out _lng3, HJS.Block.BlockId.IdLngFR, false);
                                if (ret == HJS.ReturnValue.NoError)
                                {
                                    LastCrcLng3 = _lng3.Checksum;
                                    ret         = _file.GetBlock(out _lng4, HJS.Block.BlockId.IdLngIT, false);
                                    if (ret == HJS.ReturnValue.NoError)
                                    {
                                        LastCrcLng4 = _lng4.Checksum;
                                        // Optional languages
                                        for (int i = 34; i < 50; i++)
                                        {
                                            //
                                            if (_lng5 == null)
                                            {
                                                ret = _file.GetBlock(out _lng5, (HJS.Block.BlockId)i, false);
                                                if (ret != HJS.ReturnValue.NoError)
                                                {
                                                    _lng5 = null;
                                                }
                                            }
                                            else if (_lng6 == null)
                                            {
                                                ret = _file.GetBlock(out _lng6, (HJS.Block.BlockId)i, false);
                                                if (ret != HJS.ReturnValue.NoError)
                                                {
                                                    _lng6 = null;
                                                }
                                            }
                                            else if (_lng7 == null)
                                            {
                                                ret = _file.GetBlock(out _lng7, (HJS.Block.BlockId)i, false);
                                                if (ret != HJS.ReturnValue.NoError)
                                                {
                                                    _lng7 = null;
                                                }
                                            }
                                            else if (_lng8 == null)
                                            {
                                                ret = _file.GetBlock(out _lng8, (HJS.Block.BlockId)i, false);
                                                if (ret != HJS.ReturnValue.NoError)
                                                {
                                                    _lng8 = null;
                                                }
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }

                                        ret = mECU.StartUpdateParameterset(ref _cfg, ref _kf, ref _lng1, ref _lng2, ref _lng3, ref _lng4, ref _lng5, ref _lng6, ref _lng7, ref _lng8);
                                        //upload still in progress !
                                        _file.Close();
                                        if (ret == HJS.ReturnValue.NoError)
                                        {
                                            return(true);
                                        }
                                        else
                                        {
                                            tellStatus(String.Format("Aufspielen fehlgeschlagen ({0})", ret));
                                            return(false);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                _file.Close();
                tellStatus(String.Format("Defekte Datei: {0}", FileName));
                return(false);
            }
            else
            {
                // je nach ret val LastErrorString setzen!
                tellStatus(String.Format("Datei konnte nicht geoeffnet werden: {0}", FileName));
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>Read a parameter set file from ECU</summary>
 /// <param name="FileName">File name of parameterset</param>
 /// <returns>True if file is uploaded successfully</returns>
 public bool ReadConfig(string FileName)
 {
     HJS.BlockFile _file = new HJS.BlockFile();
     HJS.Block     _cfg  = mECU.GetBlock(HJS.Block.BlockId.IdKonfig);
     return(false);
 }