private void button3_Click(object sender, EventArgs e) { if (CPUCardWrapper.ReadFile(GetCurrentFileID(), out string msg)) { txtoutput.Text = msg; WireLog("读取成功" + msg); } else { txtoutput.Text = "读取失败" + msg; WireLog("读取失败" + msg); } }
private void button11_Click(object sender, EventArgs e) { string data = GetRandomData(30000); CPUCardWrapper.CreateFile(GetCurrentFileID(), data, out string msg); CPUCardWrapper.ReadFile(GetCurrentFileID(), out string readData); if (data == readData) { MessageBox.Show("成功"); } else { Console.WriteLine(); } }
private void button10_Click(object sender, EventArgs e) { txtoutput.Text = ""; for (ushort i = 1; i < maxFileID; i++) { txtoutput.AppendText("--------------------------------------\r\n"); if (CPUCardWrapper.ReadFile(i, out string msg)) { txtoutput.AppendText(i + "读取成功" + msg + "\r\n"); } else { txtoutput.AppendText(i + "读取失败" + msg + "\r\n"); } } }
public static bool TestFileByte(ushort fileId, byte[] fileContent) { bool isPass = true; DateTime dtStart = DateTime.Now; if (!CPUCardWrapper.CreateFile(fileId, fileContent, out string msg)) { Console.WriteLine("创建文件失败" + msg); isPass = false; } DateTime dtEnd = DateTime.Now; TimeSpan ts = dtEnd - dtStart; Console.WriteLine(); dtStart = DateTime.Now; byte[] readData = new byte[0]; if (!CPUCardWrapper.ReadFile(fileId, out readData, out string m3sg)) { Console.WriteLine("读取文件失败" + m3sg); isPass = false; } dtEnd = DateTime.Now; ts = dtEnd - dtStart; Console.WriteLine(); if (!compData(fileContent, readData)) { int count = fileContent.Length - m3sg.Length; Console.WriteLine("写入文件与读取文件不一致,读取比写入少" + count); isPass = false; } string result = "测试文件{0} ,测试长度{1},测试结果{2}"; Console.WriteLine(string.Format(result, fileId, fileContent.Length, isPass ? "通过" : "不通过")); return(isPass); }
public static void ReadALlCard() { //string fileName = $"cpudata-{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}-{DateTime.Now.Hour}-{DateTime.Now.Second}-{DateTime.Now.Second}-{DateTime.Now.Millisecond}.log"; //StreamWriter sw = File.CreateText(fileName); for (ushort i = 1; i <= 100; i++) { //sw.WriteLine(i.ToString()); if (CPUCardWrapper.ReadFile(i, out string msg)) { Console.WriteLine(i + "分区读取失败" + msg); // sw.WriteLine(i + "分区读取成功" + msg); } else { Console.WriteLine(i + "分区读取失败" + msg); //sw.WriteLine(i + "分区读取失败" + msg); } } }