• 大小: 43KB
    文件类型: .7z
    金币: 1
    下载: 0 次
    发布日期: 2021-06-01
  • 语言: 其他
  • 标签: S19  车辆诊断  升级  

资源简介

S19文件解析,将S19文件格式中的有效数据提取出来,进而可以对车辆的控制器进行运用诊断协议升级

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace S19ToBin
{
    struct RowStruct
    {
        public string Type;
        public byte Length;
        public string StartAddress;  
        public string Rdata;
        public string Crc;
    };

    public partial class Form1 : Form
    {
        public static List listBuffer = new List(); //存储全部flashing升级文件   
        public static List liststring = new List(); //存储全部flashing
  
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            OpenFileDialog fileDialogBootLoader = new OpenFileDialog();
            string strPath = System.Environment.CurrentDirectory;
            liststring.Clear();
            listBuffer.Clear();

            fileDialogBootLoader.InitialDirectory = strPath;
            fileDialogBootLoader.title = “Please Choose an Upgrade File“;
            fileDialogBootLoader.Filter = “ldr files (*.ldr)|*.ldr | All files (*.*) |*.*“;
            fileDialogBootLoader.FilterIndex = 2;
            fileDialogBootLoader.RestoreDirectory = true;

            if (fileDialogBootLoader.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string strFile = fileDialogBootLoader.FileName;
            StreamReader _rstream = new StreamReader(strFile System.Text.Encoding.Default);           
            string line;
            while ((line = _rstream.ReadLine()) != null)
            {
                liststring.Add(line);
            }
            _rstream.Close();

            for (int i = 0; i < liststring.Count; i++ )
            {
                RowStruct RowStructTemp = new RowStruct();
                
                int iAddrLength = 0;
                bool bSucess = false;
                if (liststring[i].Length < 2)
                {
                    liststring.Clear();
                    listBuffer.Clear();
                    MessageBox.Show(“S19文件格式错误“);
                    return;
                }
                RowStructTemp.Type = liststring[i].Substring(0 2);

                switch (RowStructTemp.Type)
                {
                case “S0“:
                    iAddrLength = 4;
                    bSucess = RowDataToStruct(liststring[i] iAddrLengthref RowStructTemp);
                    if (!bSucess)
                    {
                        liststring.Clear();
                        listBuffer.Clear();
                        MessageBox.Show(“S19文件格式错误“);
                        return;
                    }
                    
                    //string strAddrAndData = RowStructTemp.StartAddress + RowStructTemp.Rdata;
              

评论

共有 条评论