Ver código fonte

1,增加指令窗口,可显示发送和接收的数据;
2,增加发送指令功能,填写ID、Mode、Cmd、Data。

Dail 10 meses atrás
pai
commit
519e42a575

BIN
.vs/Welling_Motor_Debug_Tool/v17/.suo


+ 28 - 1
Welling_Motor_Debug_Tool/Serial_Process.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.IO.Ports;
 using System.Linq;
 using System.Text;
@@ -217,6 +218,19 @@ namespace Welling_Motor_Debug_Tool
             //发送数据
             mySerial.Write(SendCmdTmp, 0, SendCmdTmp.Length);
 
+            //串口发送的数据显示在子窗口
+            if (mainForm.mainform1.DebugWindowIsOpen && mainForm.mainform1.DebugDataDisplayEnable)
+            {
+                string strTemp = String.Empty;
+                strTemp += System.DateTimeOffset.Now.ToString("HH:mm:ss.fff") + " --> ";
+                for (int i = 0; i < SendCmdTmp.Length; i++)
+                {
+                    strTemp += (SendCmdTmp[i].ToString("X2") + " ");
+                }
+                DebugForm.debug1.richTextBox_DebugSend.Text += strTemp;
+                DebugForm.debug1.richTextBox_DebugSend.Text += "\r\n";
+            }
+            
             return true;
         }
         #endregion 
@@ -263,6 +277,19 @@ namespace Welling_Motor_Debug_Tool
             //发送数据
             mySerial.Write(SendCmdTmp, 0, SendCmdTmp.Length);
 
+            //串口发送的数据显示在子窗口
+            if (mainForm.mainform1.DebugWindowIsOpen && mainForm.mainform1.DebugDataDisplayEnable)
+            {
+                string strTemp = String.Empty;
+                strTemp += System.DateTimeOffset.Now.ToString("HH:mm:ss.fff") + " --> ";
+                for (int i = 0; i < SendCmdTmp.Length; i++)
+                {
+                    strTemp += (SendCmdTmp[i].ToString("X2") + " ");
+                }
+                DebugForm.debug1.richTextBox_DebugSend.Text += strTemp;
+                DebugForm.debug1.richTextBox_DebugSend.Text += "\r\n";
+            }
+
             return true;
         }
 
@@ -286,7 +313,7 @@ namespace Welling_Motor_Debug_Tool
                 });
 
 */               
-                buffer.AddRange(buf);//将读取的数据放入buffer中
+                buffer.AddRange(buf);//将读取的数据放入buffer中   
             }
             catch (Exception)
             {

+ 11 - 1
Welling_Motor_Debug_Tool/Version.cs

@@ -17,7 +17,17 @@ namespace Welling_Motor_Debug_Tool
         //修改记录
         string ChangeLog = "修改记录:\r\n" +
             "V" + mainForm.Version + "\r\n" +
-            "1,优化修改配置模式时重复发送指令的问题。\r\n\r\n" +
+            "1,增加自动更新按钮,解决离线使用是打开慢的问题;\r\n" +
+            "2,删除发送进入5S协议指令,新版本UART控制器不需要配置协议,考虑还原提高兼容性;\r\n" +
+            "3,部分工序增加延时,解决通信异常问题;\r\n" +
+            "4,量产测试和检验模式增加重发机制;\r\n" +
+            "5,控制参数预留1低8位作为转把定速巡航开关,仪表用户参数增加转把定速巡航开关;\r\n" +
+            "6, 增加指令窗口,可显示接收和发送的数据;\r\n" +
+            "7,解决导入本地记录文件是,自定义字符串以\\0结尾高级参数界面异常问题,目前关闭自定义字符串指令。\r\n\r\n" +
+            "V2.2.1\r\n" +
+            "1,优化修改配置模式时重复发送指令的问题;\r\n" +
+            "2,解决刹车检测报错的问题;\r\n" +
+            "3,解决力矩传感器测试结果不显示问题吧。\r\n\r\n" +
             "V2.2.0\r\n" +
             "1,优化新增协议内容;\r\n" +
             "2,增加协议类型选择,支持CAN和UART;\r\n" +

+ 9 - 0
Welling_Motor_Debug_Tool/Welling_Motor_Debug_Tool.csproj

@@ -66,6 +66,12 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="DebugForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="DebugForm.Designer.cs">
+      <DependentUpon>DebugForm.cs</DependentUpon>
+    </Compile>
     <Compile Include="GenerateParams.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -111,6 +117,9 @@
     <Compile Include="Version.Designer.cs">
       <DependentUpon>Version.cs</DependentUpon>
     </Compile>
+    <EmbeddedResource Include="DebugForm.resx">
+      <DependentUpon>DebugForm.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="GenerateParams.resx">
       <DependentUpon>GenerateParams.cs</DependentUpon>
     </EmbeddedResource>

+ 1 - 0
Welling_Motor_Debug_Tool/ftp.cs

@@ -42,6 +42,7 @@ namespace Welling_Motor_Debug_Tool
             {
                 Uri uri = new Uri(string.Format("ftp://" + serverIP + ":" + serverPort));
                 FtpWebRequest ftpRequest = (FtpWebRequest)FtpWebRequest.Create(uri);
+                ftpRequest.Timeout = 3000;
                 ftpRequest.Credentials = new NetworkCredential(userId, passWord);
                 ftpRequest.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;
                 FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();

+ 60 - 50
Welling_Motor_Debug_Tool/mainForm.Designer.cs

@@ -480,7 +480,6 @@ namespace Welling_Motor_Debug_Tool
             this.comboBox_FacModeCfgDate = new System.Windows.Forms.ComboBox();
             this.groupBox2 = new System.Windows.Forms.GroupBox();
             this.checkBox_FacMode_MosCal = new System.Windows.Forms.CheckBox();
-            this.pictureBox_WriteLock = new System.Windows.Forms.PictureBox();
             this.checkBox_FacCad = new System.Windows.Forms.CheckBox();
             this.checkBox_FacLightTest = new System.Windows.Forms.CheckBox();
             this.checkBox_FacBreakTest = new System.Windows.Forms.CheckBox();
@@ -521,7 +520,6 @@ namespace Welling_Motor_Debug_Tool
             this.richTextBox_CheckModeLog = new System.Windows.Forms.RichTextBox();
             this.groupBox29 = new System.Windows.Forms.GroupBox();
             this.checkBox_CheckModeMos = new System.Windows.Forms.CheckBox();
-            this.pictureBox_ReadLock = new System.Windows.Forms.PictureBox();
             this.checkBox_CheckModeSN = new System.Windows.Forms.CheckBox();
             this.checkBox_CheckModeTorque = new System.Windows.Forms.CheckBox();
             this.checkBox_CheckModeCfg = new System.Windows.Forms.CheckBox();
@@ -618,10 +616,13 @@ namespace Welling_Motor_Debug_Tool
             this.label106 = new System.Windows.Forms.Label();
             this.label107 = new System.Windows.Forms.Label();
             this.label_StarInfo = new System.Windows.Forms.Label();
-            this.pictureBox2 = new System.Windows.Forms.PictureBox();
             this.label_UserName = new System.Windows.Forms.Label();
             this.label124 = new System.Windows.Forms.Label();
             this.label46 = new System.Windows.Forms.Label();
+            this.pictureBox_WriteLock = new System.Windows.Forms.PictureBox();
+            this.pictureBox_ReadLock = new System.Windows.Forms.PictureBox();
+            this.pictureBox2 = new System.Windows.Forms.PictureBox();
+            this.发送指令ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.menuStrip_Set.SuspendLayout();
             this.statusStrip1.SuspendLayout();
             this.groupBox1.SuspendLayout();
@@ -672,15 +673,15 @@ namespace Welling_Motor_Debug_Tool
             this.groupBox28.SuspendLayout();
             this.groupBox27.SuspendLayout();
             this.groupBox2.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_WriteLock)).BeginInit();
             this.tabPage_ProductMode_Read.SuspendLayout();
             this.groupBox31.SuspendLayout();
             this.groupBox30.SuspendLayout();
             this.groupBox29.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_ReadLock)).BeginInit();
             this.tabControl2.SuspendLayout();
             this.tabPage_RunInfo.SuspendLayout();
             this.tabPage_DebugInfo.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_WriteLock)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_ReadLock)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
             this.SuspendLayout();
             // 
@@ -1401,7 +1402,8 @@ namespace Welling_Motor_Debug_Tool
             this.页面保存ToolStripMenuItem,
             this.屏幕键盘ToolStripMenuItem,
             this.删除远程文件ToolStripMenuItem,
-            this.指令调试ToolStripMenuItem});
+            this.指令调试ToolStripMenuItem,
+            this.发送指令ToolStripMenuItem});
             this.工具箱ToolStripMenuItem.ForeColor = System.Drawing.Color.White;
             this.工具箱ToolStripMenuItem.Name = "工具箱ToolStripMenuItem";
             this.工具箱ToolStripMenuItem.Size = new System.Drawing.Size(70, 25);
@@ -1410,28 +1412,28 @@ namespace Welling_Motor_Debug_Tool
             // 运行信息记录ToolStripMenuItem
             // 
             this.运行信息记录ToolStripMenuItem.Name = "运行信息记录ToolStripMenuItem";
-            this.运行信息记录ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
+            this.运行信息记录ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
             this.运行信息记录ToolStripMenuItem.Text = "自动记录";
             this.运行信息记录ToolStripMenuItem.Click += new System.EventHandler(this.记录数据ToolStripMenuItem_Click);
             // 
             // 计算器ToolStripMenuItem
             // 
             this.计算器ToolStripMenuItem.Name = "计算器ToolStripMenuItem";
-            this.计算器ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
+            this.计算器ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
             this.计算器ToolStripMenuItem.Text = "计算器";
             this.计算器ToolStripMenuItem.Click += new System.EventHandler(this.计算器ToolStripMenuItem_Click);
             // 
             // 页面保存ToolStripMenuItem
             // 
             this.页面保存ToolStripMenuItem.Name = "页面保存ToolStripMenuItem";
-            this.页面保存ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
+            this.页面保存ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
             this.页面保存ToolStripMenuItem.Text = "页面保存";
             this.页面保存ToolStripMenuItem.Click += new System.EventHandler(this.页面保存ToolStripMenuItem_Click);
             // 
             // 屏幕键盘ToolStripMenuItem
             // 
             this.屏幕键盘ToolStripMenuItem.Name = "屏幕键盘ToolStripMenuItem";
-            this.屏幕键盘ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
+            this.屏幕键盘ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
             this.屏幕键盘ToolStripMenuItem.Text = "屏幕键盘";
             this.屏幕键盘ToolStripMenuItem.Click += new System.EventHandler(this.屏幕键盘ToolStripMenuItem_Click);
             // 
@@ -1441,7 +1443,7 @@ namespace Welling_Motor_Debug_Tool
             this.生产配置文件ToolStripMenuItem,
             this.样机测试记录ToolStripMenuItem});
             this.删除远程文件ToolStripMenuItem.Name = "删除远程文件ToolStripMenuItem";
-            this.删除远程文件ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
+            this.删除远程文件ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
             this.删除远程文件ToolStripMenuItem.Text = "删除远程文件";
             // 
             // 生产配置文件ToolStripMenuItem
@@ -1478,10 +1480,10 @@ namespace Welling_Motor_Debug_Tool
             // 
             // 指令调试ToolStripMenuItem
             // 
-            this.指令调试ToolStripMenuItem.Enabled = false;
             this.指令调试ToolStripMenuItem.Name = "指令调试ToolStripMenuItem";
-            this.指令调试ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
-            this.指令调试ToolStripMenuItem.Text = "指令调试";
+            this.指令调试ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.指令调试ToolStripMenuItem.Text = "指令窗口";
+            this.指令调试ToolStripMenuItem.Click += new System.EventHandler(this.指令调试ToolStripMenuItem_Click);
             // 
             // 查询ToolStripMenuItem
             // 
@@ -5486,17 +5488,6 @@ namespace Welling_Motor_Debug_Tool
             this.checkBox_FacMode_MosCal.Text = "MOS校准";
             this.checkBox_FacMode_MosCal.UseVisualStyleBackColor = true;
             // 
-            // pictureBox_WriteLock
-            // 
-            this.pictureBox_WriteLock.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.Lock;
-            this.pictureBox_WriteLock.Location = new System.Drawing.Point(100, 28);
-            this.pictureBox_WriteLock.Name = "pictureBox_WriteLock";
-            this.pictureBox_WriteLock.Size = new System.Drawing.Size(45, 45);
-            this.pictureBox_WriteLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
-            this.pictureBox_WriteLock.TabIndex = 7;
-            this.pictureBox_WriteLock.TabStop = false;
-            this.pictureBox_WriteLock.Click += new System.EventHandler(this.pictureBox_WriteLock_Click);
-            // 
             // checkBox_FacCad
             // 
             this.checkBox_FacCad.AutoSize = true;
@@ -6015,17 +6006,6 @@ namespace Welling_Motor_Debug_Tool
             this.checkBox_CheckModeMos.Text = "MOS内阻校准确认";
             this.checkBox_CheckModeMos.UseVisualStyleBackColor = true;
             // 
-            // pictureBox_ReadLock
-            // 
-            this.pictureBox_ReadLock.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.Lock;
-            this.pictureBox_ReadLock.Location = new System.Drawing.Point(149, 28);
-            this.pictureBox_ReadLock.Name = "pictureBox_ReadLock";
-            this.pictureBox_ReadLock.Size = new System.Drawing.Size(45, 45);
-            this.pictureBox_ReadLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
-            this.pictureBox_ReadLock.TabIndex = 8;
-            this.pictureBox_ReadLock.TabStop = false;
-            this.pictureBox_ReadLock.Click += new System.EventHandler(this.pictureBox_ReadLock_Click);
-            // 
             // checkBox_CheckModeSN
             // 
             this.checkBox_CheckModeSN.AutoSize = true;
@@ -7020,17 +7000,6 @@ namespace Welling_Motor_Debug_Tool
             this.label_StarInfo.Text = "选择正确端口\r\n连接成功后开始使用";
             this.label_StarInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
             // 
-            // pictureBox2
-            // 
-            this.pictureBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
-            this.pictureBox2.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.logo;
-            this.pictureBox2.Location = new System.Drawing.Point(896, 3);
-            this.pictureBox2.Name = "pictureBox2";
-            this.pictureBox2.Size = new System.Drawing.Size(132, 23);
-            this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
-            this.pictureBox2.TabIndex = 16;
-            this.pictureBox2.TabStop = false;
-            // 
             // label_UserName
             // 
             this.label_UserName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
@@ -7063,6 +7032,46 @@ namespace Welling_Motor_Debug_Tool
             this.label46.TabIndex = 21;
             this.label46.Text = "/";
             // 
+            // pictureBox_WriteLock
+            // 
+            this.pictureBox_WriteLock.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.Lock;
+            this.pictureBox_WriteLock.Location = new System.Drawing.Point(100, 28);
+            this.pictureBox_WriteLock.Name = "pictureBox_WriteLock";
+            this.pictureBox_WriteLock.Size = new System.Drawing.Size(45, 45);
+            this.pictureBox_WriteLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+            this.pictureBox_WriteLock.TabIndex = 7;
+            this.pictureBox_WriteLock.TabStop = false;
+            this.pictureBox_WriteLock.Click += new System.EventHandler(this.pictureBox_WriteLock_Click);
+            // 
+            // pictureBox_ReadLock
+            // 
+            this.pictureBox_ReadLock.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.Lock;
+            this.pictureBox_ReadLock.Location = new System.Drawing.Point(149, 28);
+            this.pictureBox_ReadLock.Name = "pictureBox_ReadLock";
+            this.pictureBox_ReadLock.Size = new System.Drawing.Size(45, 45);
+            this.pictureBox_ReadLock.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+            this.pictureBox_ReadLock.TabIndex = 8;
+            this.pictureBox_ReadLock.TabStop = false;
+            this.pictureBox_ReadLock.Click += new System.EventHandler(this.pictureBox_ReadLock_Click);
+            // 
+            // pictureBox2
+            // 
+            this.pictureBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
+            this.pictureBox2.Image = global::Welling_Motor_Debug_Tool.Properties.Resources.logo;
+            this.pictureBox2.Location = new System.Drawing.Point(896, 3);
+            this.pictureBox2.Name = "pictureBox2";
+            this.pictureBox2.Size = new System.Drawing.Size(132, 23);
+            this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+            this.pictureBox2.TabIndex = 16;
+            this.pictureBox2.TabStop = false;
+            // 
+            // 发送指令ToolStripMenuItem
+            // 
+            this.发送指令ToolStripMenuItem.Name = "发送指令ToolStripMenuItem";
+            this.发送指令ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
+            this.发送指令ToolStripMenuItem.Text = "发送指令";
+            this.发送指令ToolStripMenuItem.Click += new System.EventHandler(this.发送指令ToolStripMenuItem_Click);
+            // 
             // mainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F);
@@ -7183,7 +7192,6 @@ namespace Welling_Motor_Debug_Tool
             this.groupBox27.ResumeLayout(false);
             this.groupBox2.ResumeLayout(false);
             this.groupBox2.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_WriteLock)).EndInit();
             this.tabPage_ProductMode_Read.ResumeLayout(false);
             this.tabPage_ProductMode_Read.PerformLayout();
             this.groupBox31.ResumeLayout(false);
@@ -7191,12 +7199,13 @@ namespace Welling_Motor_Debug_Tool
             this.groupBox30.ResumeLayout(false);
             this.groupBox29.ResumeLayout(false);
             this.groupBox29.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_ReadLock)).EndInit();
             this.tabControl2.ResumeLayout(false);
             this.tabPage_RunInfo.ResumeLayout(false);
             this.tabPage_RunInfo.PerformLayout();
             this.tabPage_DebugInfo.ResumeLayout(false);
             this.tabPage_DebugInfo.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_WriteLock)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_ReadLock)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
@@ -7581,7 +7590,6 @@ namespace Welling_Motor_Debug_Tool
         private Label label110;
         private Label label108;
         private Label label111;
-        private ToolStripMenuItem 指令调试ToolStripMenuItem;
         private Label label_StarInfo;
         private TextBox textBox_FacModeScan;
         private Label label112;
@@ -7794,5 +7802,7 @@ namespace Welling_Motor_Debug_Tool
         private ComboBox comboBox_Bike_CCS;
         public ComboBox comboBox_OBC_BikeCCS;
         private Label label137;
+        public ToolStripMenuItem 指令调试ToolStripMenuItem;
+        private ToolStripMenuItem 发送指令ToolStripMenuItem;
     }
 }

+ 216 - 31
Welling_Motor_Debug_Tool/mainForm.cs

@@ -23,7 +23,7 @@ namespace Welling_Motor_Debug_Tool
     {
         #region 变量定义
         //版本号
-        public static string Version = "2.2.1";
+        public static string Version = "2.2.2";
         //串口实例
         Serial_Process mySerialProcess = new Serial_Process();
         string PortNumSave = "";
@@ -74,6 +74,8 @@ namespace Welling_Motor_Debug_Tool
         public static Version VersionForm = new Version();
         //本机硬件信息
         public string Local_HdInformation = "";
+        //指令窗口显示
+        public bool DebugWindowIsOpen = false, DebugDataDisplayEnable = false;
         #endregion
 
         #region 故障日志结构体定义
@@ -247,9 +249,11 @@ namespace Welling_Motor_Debug_Tool
 
         #endregion
 
+        public static mainForm mainform1 = null;
         public mainForm()
         {
             InitializeComponent();
+            mainform1 = this;
             System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
             stopwatch.Start();
 
@@ -675,8 +679,10 @@ namespace Welling_Motor_Debug_Tool
             //创建线程,定时检测网络连接状态
             Thread th = new Thread(NetworkCheck);
             th.IsBackground = true;
-            th.Start();            
-            
+            th.Start();
+
+            //允许跨线程访问
+            Control.CheckForIllegalCrossThreadCalls = false;
         }
 
         /// <summary>
@@ -1117,9 +1123,21 @@ namespace Welling_Motor_Debug_Tool
                                     {
                                         Data[i] = buffer[i + 8];
                                     }
+                                    // 串口接收的数据  显示在子窗口
+                                    if (this.DebugWindowIsOpen && this.DebugDataDisplayEnable)
+                                    {
+                                        string strTemp = String.Empty;
+                                        strTemp += System.DateTimeOffset.Now.ToString("HH:mm:ss.fff") + " <-- ";
+                                        for (int i = 0; i < CmdLen + 11; i++)
+                                        {                                            
+                                            strTemp += (buffer[i].ToString("X2") + " ");
+                                        }
+                                        strTemp += "\n";
+                                        DebugForm.debug1.richTextBox_DebugRev.Text += strTemp;
+                                    }
                                     buffer.RemoveRange(0, CmdLen + 11);
                                     DataCmdProcess(PackageID, Cmd, Data);//对于不同的命令段,做不同的处理
-                                    DataRevToString(Cmd, Data);//指令数据转为字符串
+                                    DataRevToString(Cmd, Data);//指令数据转为字符串                                    
                                 }
                             }
                         }
@@ -5983,11 +6001,11 @@ namespace Welling_Motor_Debug_Tool
 
             //发送开机指令                        
             //确保测试前先关机,发送关机指令再发送开机指令
-            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送机指令" + "\r\n");
+            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送机指令" + "\r\n");
             Code[0] = 0xF0;
             mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
             Delay_ms(1500);
-            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送机指令" + "\r\n");
+            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送机指令" + "\r\n");
             Code[0] = 0xF1;
             mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
             ACK_WaitCnt = 0;
@@ -7949,6 +7967,7 @@ namespace Welling_Motor_Debug_Tool
             string ResultPathName = "";
 
             label_CheckModeStatus.Text = "开始测试";
+            BootInfo = "";
             Delay_ms(500);
             label_CheckModeStatus.Text = "系统开机";
 
@@ -7965,14 +7984,17 @@ namespace Welling_Motor_Debug_Tool
             }
 
             //系统开机,确保测试前先关机,发送关机指令再发送开机指令
-            BootInfo = "";
+            //确保测试前先关机,发送关机指令再发送开机指令
+            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送关机指令" + "\r\n");
             Code[0] = 0xF0;
             mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
             Delay_ms(1500);
+            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送开机指令" + "\r\n");
             Code[0] = 0xF1;
             mySerialProcess.SendCmd(0x7FF, 0x16, 0x2201, Code);
             ACK_WaitCnt = 0;
-            while (ACK_WaitCnt <= 15) ; //7.5s            
+            richTextBox_FacModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "等待控制器返回Boot信息……" + "\r\n");
+            while (ACK_WaitCnt <= 20) ; //10s            
 
             //检查BOOT版本
             if (BootInfo != string.Empty)
@@ -8269,14 +8291,70 @@ namespace Welling_Motor_Debug_Tool
                         Delay_ms(500);
                         if (CmdRevStrTemp == string.Empty)
                         {
-                            richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + key + "指令读取失败" + "\r\n");
-                            label_CheckModeStatus.Text = "存在故障!";
-                            label_CheckModeResult.BackColor = Color.Red;
-                            label_CheckModeResult.Text = "测试异常";
+                            richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送读" + key + "指令,第1次重发" + "\r\n");
+                            if (key.Contains("曲线"))
+                            {
+                                byte LineNum = 0;
+                                var code = new byte[4];
+                                LineNum = Convert.ToByte(key.Substring(3, key.Length - 4));
+                                if (LineNum <= 5)
+                                {
+                                    code[0] = (byte)(LineNum & 0xFF);
+                                    code[1] = (byte)((LineNum >> 8) & 0xFF);
+                                    code[2] = (byte)(LineNum & 0xFF);
+                                    code[3] = (byte)((LineNum >> 8) & 0xFF);
+                                }
+                                else
+                                {
+                                    code[0] = (byte)(LineNum & 0xFF);
+                                    code[1] = (byte)((LineNum >> 8) & 0xFF);
+                                    code[2] = (byte)(5 & 0xFF);
+                                    code[3] = (byte)((5 >> 8) & 0xFF);
+                                }
+                                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)myParams.ConfigCheckReadCmd["[助力参数]"], code);
+                            }
+                            else
+                                mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)myParams.ConfigCheckReadCmd[key], null);
                             Delay_ms(500);
-                            //存储异常并上传
-                            CheckMode_Stop(false);
-                            return;
+                            if (CmdRevStrTemp == string.Empty)
+                            {
+                                richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "发送读" + key + "指令,第2次重发" + "\r\n");
+                                if (key.Contains("曲线"))
+                                {
+                                    byte LineNum = 0;
+                                    var code = new byte[4];
+                                    LineNum = Convert.ToByte(key.Substring(3, key.Length - 4));
+                                    if (LineNum <= 5)
+                                    {
+                                        code[0] = (byte)(LineNum & 0xFF);
+                                        code[1] = (byte)((LineNum >> 8) & 0xFF);
+                                        code[2] = (byte)(LineNum & 0xFF);
+                                        code[3] = (byte)((LineNum >> 8) & 0xFF);
+                                    }
+                                    else
+                                    {
+                                        code[0] = (byte)(LineNum & 0xFF);
+                                        code[1] = (byte)((LineNum >> 8) & 0xFF);
+                                        code[2] = (byte)(5 & 0xFF);
+                                        code[3] = (byte)((5 >> 8) & 0xFF);
+                                    }
+                                    mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)myParams.ConfigCheckReadCmd["[助力参数]"], code);
+                                }
+                                else
+                                    mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)myParams.ConfigCheckReadCmd[key], null);
+                                Delay_ms(500);
+                                if (CmdRevStrTemp == string.Empty)
+                                {
+                                    richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + key + "指令读取失败" + "\r\n");
+                                    label_CheckModeStatus.Text = "存在故障!";
+                                    label_CheckModeResult.BackColor = Color.Red;
+                                    label_CheckModeResult.Text = "测试异常";
+                                    Delay_ms(500);
+                                    //存储异常并上传
+                                    CheckMode_Stop(false);
+                                    return;
+                                }
+                            } 
                         }
                         //比较当前指令,读取的配置文件和返回数据比较
                         string ParamWrite = ConfigCmd[key].Substring(24, ConfigCmd[key].Length - 40).Trim();
@@ -8334,14 +8412,28 @@ namespace Welling_Motor_Debug_Tool
                 while (ACK_WaitCnt <= 2) ; //1s
                 if (CmdRevStrTemp == "---")
                 {
-                    richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "力矩传感器读取失败" + "\r\n");
-                    label_CheckModeStatus.Text = "存在故障!";
-                    label_CheckModeResult.BackColor = Color.Red;
-                    label_CheckModeResult.Text = "测试异常";
-                    Delay_ms(500);
-                    //存储异常并上传
-                    CheckMode_Stop(false);
-                    return;
+                    richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取力矩传感器标定数据,第1次重发" + "\r\n");
+                    mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, 0x4000, null);
+                    ACK_WaitCnt = 0;
+                    while (ACK_WaitCnt <= 2) ; //1s
+                    if (CmdRevStrTemp == "---")
+                    {
+                        richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取力矩传感器标定数据,第2次重发" + "\r\n");
+                        mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, 0x4000, null);
+                        ACK_WaitCnt = 0;
+                        while (ACK_WaitCnt <= 2) ; //1s
+                        if (CmdRevStrTemp == "---")
+                        {
+                            richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "力矩传感器读取失败" + "\r\n");
+                            label_CheckModeStatus.Text = "存在故障!";
+                            label_CheckModeResult.BackColor = Color.Red;
+                            label_CheckModeResult.Text = "测试异常";
+                            Delay_ms(500);
+                            //存储异常并上传
+                            CheckMode_Stop(false);
+                            return;
+                        }
+                    }    
                 }
                 richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "力矩传感器读取成功" + "\r\n");
                 //取力矩传感器数据
@@ -8430,14 +8522,28 @@ namespace Welling_Motor_Debug_Tool
                     while (ACK_WaitCnt <= 2) ; //1s
                     if ((textBox_MOS_R1.Text == string.Empty) || (textBox_MOS_R2.Text == string.Empty) || (textBox_MOS_R3.Text == string.Empty))
                     {
-                        richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取MOS内阻校准结果异常" + "\r\n");
-                        label_CheckModeStatus.Text = "存在故障!";
-                        label_CheckModeResult.BackColor = Color.Red;
-                        label_CheckModeResult.Text = "测试异常";
-                        Delay_ms(500);
-                        //存储异常并上传
-                        CheckMode_Stop(false);
-                        return;
+                        richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取MOS内阻校准数据,第1次重发" + "\r\n");
+                        mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4B00, null);
+                        ACK_WaitCnt = 0;
+                        while (ACK_WaitCnt <= 2) ; //1s
+                        if ((textBox_MOS_R1.Text == string.Empty) || (textBox_MOS_R2.Text == string.Empty) || (textBox_MOS_R3.Text == string.Empty))
+                        {
+                            richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取MOS内阻校准数据,第2次重发" + "\r\n");
+                            mySerialProcess.SendCmd((ushort)0x751, (byte)0x11, (ushort)0x4B00, null);
+                            ACK_WaitCnt = 0;
+                            while (ACK_WaitCnt <= 2) ; //1s
+                            if ((textBox_MOS_R1.Text == string.Empty) || (textBox_MOS_R2.Text == string.Empty) || (textBox_MOS_R3.Text == string.Empty))
+                            {
+                                richTextBox_CheckModeLog.AppendText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "->" + "读取MOS内阻校准结果异常" + "\r\n");
+                                label_CheckModeStatus.Text = "存在故障!";
+                                label_CheckModeResult.BackColor = Color.Red;
+                                label_CheckModeResult.Text = "测试异常";
+                                Delay_ms(500);
+                                //存储异常并上传
+                                CheckMode_Stop(false);
+                                return;
+                            }
+                        }   
                     }
                     else
                     {
@@ -9428,5 +9534,84 @@ namespace Welling_Motor_Debug_Tool
             //  设置伴随的对象.
             toolTip1.SetToolTip(this.comboBox_CheckModeCfgFile, comboBox_CheckModeCfgFile.Text);//设置故障内容显示
         }
+
+        /// <summary>
+        /// 手动发送指令
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void 发送指令ToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            //提示
+            MessageBoxTimeOut.Show("按照16进制填写,相邻字节用空格隔开\r\n依次填写ID、Mode、Cmd、Data\r\n例如:07 31 16 22 05 01 02 03 04 05", "提示", 3000, MessageBoxButtons.OK, MessageBoxIcon.Information);
+
+            Scan scan_form = new Scan();
+            scan_form.ShowDialog();
+                        
+            //发送写入的指令,填写ID、类型、命令字、数据
+            do
+            {
+                if (scan_form.textBox_Scan.Text == string.Empty)
+                {
+                    timer_1s.Enabled = false;
+                    MessageBox.Show("无内容!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                    timer_1s.Enabled = true;
+                    break;
+                }
+
+                //输入文本转换为字节流
+                var InputData = new byte[256];
+                InputData = mySerialProcess.HexStringToBytes(scan_form.textBox_Scan.Text, true);
+                //ID
+                ushort ID;
+                ID = (ushort)((InputData[0] << 8) + InputData[1]);
+                //Mode
+                byte Mode;
+                Mode = InputData[2];
+                //Cmd
+                ushort Cmd;
+                Cmd = (ushort)((InputData[3] << 8) + InputData[4]);
+                //Data
+                var Data = new byte[Cmd & 0x00FF];
+                for (int i = 0; i < (Cmd & 0x00FF); i++)
+                    Data[i] = InputData[5 + i];
+                //发送数据
+                mySerialProcess.SendCmdWithoutNotice(ID, Mode, Cmd, Data);
+            } while (false);
+        }
+
+        /// <summary>
+        /// 打开或关闭指令窗口
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void 指令调试ToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            if (指令调试ToolStripMenuItem.Checked == false)
+            {
+                if (DebugForm.debug1 == null || DebugForm.debug1.IsDisposed)
+                {
+                    DebugForm.debug1 = new DebugForm();
+                    DebugForm.debug1.Show();
+                    this.DebugWindowIsOpen = true;
+                }
+                else
+                {
+                    DebugForm.debug1.Activate();
+                    this.DebugWindowIsOpen = true;
+                }
+                指令调试ToolStripMenuItem.Checked = true;
+            }
+            else
+            {
+                if (this.DebugWindowIsOpen == true)
+                {
+                    DebugForm.debug1.Close();
+                    this.DebugWindowIsOpen = false;
+                    this.DebugDataDisplayEnable = false;
+                }
+                指令调试ToolStripMenuItem.Checked = false;
+            }
+        }
     }
 }

BIN
Welling_Motor_Debug_Tool/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 1 - 1
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-7d07050510310e55bf8550d9eca9cee89d28efbe0ae4d90d40193d6cce53ea30
+78a282fe404e6fe5afb89767c481f4b194a9c157db24aa161a297111cab76ee1

+ 1 - 0
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.FileListAbsolute.txt

@@ -84,3 +84,4 @@ D:\笔记本20221223\zhouxiong9\Documents\Tools\motor-debug\Welling_Motor_Debug_
 D:\笔记本20221223\zhouxiong9\Documents\Tools\motor-debug\Welling_Motor_Debug_Tool\obj\Debug\Welling_Motor_Debug_Tool.exe
 D:\笔记本20221223\zhouxiong9\Documents\Tools\motor-debug\Welling_Motor_Debug_Tool\obj\Debug\Welling_Motor_Debug_Tool.pdb
 C:\Users\hero\Documents\Work\SoftDesign\Welling-MidMotor\Welling_Motor_Debug_Tool\obj\Debug\Welling_Motor_Debug_Tool.Version.resources
+D:\笔记本20221223\zhouxiong9\Documents\Tools\motor-debug\Welling_Motor_Debug_Tool\obj\Debug\Welling_Motor_Debug_Tool.DebugForm.resources

BIN
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.csproj.GenerateResource.cache


BIN
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.exe


BIN
Welling_Motor_Debug_Tool/obj/Debug/Welling_Motor_Debug_Tool.pdb