Ejemplo n.º 1
0
 private bool keepAlive()
 {
     if (carSelected != null)
     {
         CanControl.sendFrame(physicalID, receiveID, CanControl.canStringToByte(flashProcess["PresentTester"].ToString()));
         return(SI.TPSI + 0x40 == CanControl.Rev[1]);
     }
     return(false);
 }
Ejemplo n.º 2
0
        public string readVersion()
        {
            if (carSelected == null)
            {
                return(null);
            }

            byte[] tmp = CanControl.canStringToByte(carSelected["SoftwareVersion"].ToString());
            CanControl.sendFrame(physicalID, receiveID, tmp);

            if (SI.RDBISI + 0x40 == CanControl.Rev[1])
            {
                return(Convert.ToString(CanControl.Rev[4], 16) + "." + Convert.ToString(CanControl.Rev[5], 16));
            }

            return("fail");
        }
Ejemplo n.º 3
0
        void sendCan()
        {
            try
            {
                processStr = sequence[processIndex.ToString()].ToString();
            }
            catch (NullReferenceException)
            {
                flashFlag = false;
                return;
            }

            mainSendData.Clear();
            mainSendData.AddRange(CanControl.canStringToByte(flashProcess[processStr].ToString()));
            ServiceIdentifier = mainSendData[0];

            switch (processStr)
            {
            case "SeedRequest":
                mainSendData.Add(securityAccess[0]);
                break;

            case "KeySend":
                byte[] seed = new byte[4];
                Array.Copy(CanControl.Rev, 3, seed, 0, 4);
                byte[] key = sec.seedToKey(seed);
                mainSendData.Add(securityAccess[1]);
                mainSendData.AddRange(key);
                break;

            case "DownloadRequest":
                if (s19File == null)
                {
                    s19File = s19.getS19File();
                    s19FileDataCRC32Value = CRC32.GetCRC_Custom(s19File);
                }
                s19Block = s19File[s19BlockIndex];
                mainSendData.AddRange(s19Block.StartAddress);
                mainSendData.AddRange(s19Block.DataLength);
                break;

            case "DataTransfer":
                int bootCacheBlockDataIndex = bootCacheBlockSequenceIndex * (bootCacheLength - 2);
                mainSendData.Add(bootCacheBlockSequenceCounter);
                for (int i = 0; i < bootCacheLength - 2; i++)
                {
                    int indexTmp = bootCacheBlockDataIndex + i;
                    if (indexTmp >= s19Block.Data.Length)
                    {
                        break;
                    }
                    mainSendData.Add(s19Block.Data[indexTmp]);
                }
                bootCacheBlockSequenceCounter = (byte)((bootCacheBlockSequenceCounter + 1) & 0xFF);
                bootCacheBlockSequenceIndex++;
                break;

            case "RoutineIdentifier":
                byte[] crc32Byte = new byte[4];
                for (int i = 0; i < 4; i++)
                {
                    crc32Byte[i] = (byte)(s19FileDataCRC32Value >> (8 * (3 - i)));
                }
                mainSendData.AddRange(crc32Byte);
                break;

            case "MemoryErase":
                mainSendData.Add(0x44);
                if (s19File == null)
                {
                    s19File = s19.getS19File();
                    s19FileDataCRC32Value = CRC32.GetCRC_Custom(s19File);
                }
                mainSendData.AddRange(s19File[s19BlockIndex].StartAddress);
                mainSendData.AddRange(s19File[s19BlockIndex].DataLength);
                break;

            default:
                break;
            }

            sendResult = CanControl.sendFrame(physicalID, receiveID, mainSendData.ToArray());
        }