inpoutx64.dll sharing path:
Link: https://pan.baidu.com/s/1rOt0xtt9EcsrFQtf7S91ag
Extraction code: 7om1
1.InpOutManager:
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace TestLEDWinFrm { public class InpOutManager { public bool IsInpOutDriverOpen { get; set; }//Whether the port is open public short PORT_INDEX { get; } = 0x66;//Port number public short EC_COMMAND_WRITE { get; } = 0X81;//EC command write public short PORT_DATA { get; } = 0X62;//Port data public string Err { get; set; }//Error message [DllImport("inpoutx64.dll", EntryPoint = "IsInpOutDriverOpen")] public static extern uint isInpOutDriverOpen(); [DllImport("inpoutx64.dll", EntryPoint = "Out32")] public static extern void Out32(short PortAddress, short Data); [DllImport("inpoutx64.dll", EntryPoint = "Inp32")] public static extern byte Inp32(short PortAddress); //[DllImport("inpout32.dll")] //private static extern void DlPortWritePortUshort(short PortAddress, ushort Data); //[DllImport("inpout32.dll")] //private static extern ushort DlPortReadPortUshort(short PortAddress); //[DllImport("inpout32.dll")] //private static extern void DlPortWritePortUlong(int PortAddress, uint Data); //[DllImport("inpout32.dll")] //private static extern uint DlPortReadPortUlong(int PortAddress); //[DllImport("inpoutx64.dll")] //private static extern bool GetPhysLong(ref int PortAddress, ref uint Data); //[DllImport("inpoutx64.dll")] //private static extern bool SetPhysLong(ref int PortAddress, ref uint Data); //[DllImport("inpoutx64.dll", EntryPoint = "IsInpOutDriverOpen")] //private static extern UInt32 IsInpOutDriverOpen_x64(); //[DllImport("inpoutx64.dll", EntryPoint = "Out32")] //private static extern void Out32_x64(short PortAddress, short Data); //[DllImport("inpoutx64.dll", EntryPoint = "Inp32")] //private static extern char Inp32_x64(short PortAddress); //[DllImport("inpoutx64.dll", EntryPoint = "DlPortWritePortUshort")] //private static extern void DlPortWritePortUshort_x64(short PortAddress, ushort Data); //[DllImport("inpoutx64.dll", EntryPoint = "DlPortReadPortUshort")] //private static extern ushort DlPortReadPortUshort_x64(short PortAddress); //[DllImport("inpoutx64.dll", EntryPoint = "DlPortWritePortUlong")] //private static extern void DlPortWritePortUlong_x64(int PortAddress, uint Data); //[DllImport("inpoutx64.dll", EntryPoint = "DlPortReadPortUlong")] //private static extern uint DlPortReadPortUlong_x64(int PortAddress); //[DllImport("inpoutx64.dll", EntryPoint = "GetPhysLong")] //private static extern bool GetPhysLong_x64(ref int PortAddress, ref uint Data); //[DllImport("inpoutx64.dll", EntryPoint = "SetPhysLong")] //private static extern bool SetPhysLong_x64(ref int PortAddress, ref uint Data); publicInpOutManager() { this.IsInpOutDriverOpen=isInpOutDriverOpen()>0?true:false; } /// <summary> /// Read port data /// </summary> /// <param name="PortAddress"></param> /// <returns></returns> public bool InputPortData(short PortAddress) { try { Inp32(PortAddress); return true; } catch(Exception ex) { this.Err = ex.Message; return false; } } //Out32(short PortAddress, short Data) public bool OutPortData(short PortAddress,short Data) { try { WaitECInputBufferEmpty(); Out32(0x66,0x81); //Out32(PORT_INDEX,EC_COMMAND_WRITE); WaitECInputBufferEmpty(); Out32(0x62,PortAddress); //Out32(PORT_DATA,PortAddress); WaitECInputBufferEmpty(); Out32(0x62,Data); //Out32(PORT_DATA,Data); return true; } catch(Exception ex) { this.Err=ex.Message; return false; } } private void WaitECInputBufferEmpty() { var IBF = 2; do { IBF = Inp32(0x66) &2; //IBF = (PORT_INDEX) & amp;2; } while (IBF == 2); } } }
namespace TestLEDWinFrm { public partial class MainWinFrm : Form { InpOutManager inpOutManager; private System.Windows.Forms.Timer timer; private int randcount = 0; public MainWinFrm() { InitializeComponent(); inpOutManager = new InpOutManager(); //Return permissions to EC //inpOutManager.OutPortData(0X32, 0X04); //inpOutManager.OutPortData(0X30, 0X21); } #region All LED lights light up test /// <summary> /// All LED lights are on for testing /// </summary> /// <param name="count">Numbers</param> public void AllLEDIllumeTest(int count) { int i = 0; while (i < count) { //Light up all LED lights inpOutManager.OutPortData(0X32, 0X01); inpOutManager.OutPortData(0X30, 0X21); Thread.Sleep(1000); //Turn off all LEDs inpOutManager.OutPortData(0X32, 0X02); inpOutManager.OutPortData(0X30, 0X21); Thread.Sleep(1000); //Return permissions to EC inpOutManager.OutPortData(0X32, 0X04); inpOutManager.OutPortData(0X30, 0X21); i + + ; } } #endregion #region Power LED light test /// <summary> /// Power LED light test /// </summary> /// <param name="count"></param> public void BatteryLedIllumTest(int count) { int i = 0; while (i < count) { //Light up the Battery indicator light inpOutManager.OutPortData(0X32, 0X03); inpOutManager.OutPortData(0X30, 0X21); Thread.Sleep(1000); //Turn off all lights inpOutManager.OutPortData(0X32, 0X02); inpOutManager.OutPortData(0X30, 0X21); Thread.Sleep(1000); //Return permissions to EC inpOutManager.OutPortData(0X32, 0X04); inpOutManager.OutPortData(0X30, 0X21); i + + ; } } #endregion #region History private void btn_StartTest_Click(object sender, EventArgs e) { //inpOutManager.InputPortData(0X32); inpOutManager.OutPortData(0X32, 0X01); //inpOutManager.InputPortData(0X30); inpOutManager.OutPortData(0X30, 0X21); } private void button1_Click(object sender, EventArgs e) { //Turn off all LEDs //inpOutManager.InputPortData(0X32); inpOutManager.OutPortData(0X32, 0X02); //inpOutManager.InputPortData(0X30); inpOutManager.OutPortData(0X30, 0X21); } private void button2_Click(object sender, EventArgs e) { //Light up the second battery led //inpOutManager.InputPortData(0X32); inpOutManager.OutPortData(0X32, 0X03); //inpOutManager.InputPortData(0X30); inpOutManager.OutPortData(0X30, 0X21); //WinIoFunction.SetPhysValue("0X32", "0X03"); //WinIoFunction.SetPhysValue("0X30", "0X21"); } private void button3_Click(object sender, EventArgs e) { //Light up the second battery led //inpOutManager.InputPortData(0X32); inpOutManager.OutPortData(0X32, 0X04); //inpOutManager.InputPortData(0X30); inpOutManager.OutPortData(0X30, 0X21); //WinIoFunction.SetPhysValue("0X32", "0X04"); //WinIoFunction.SetPhysValue("0X30", "0X21"); } #endregion #region Close private void btn_Close_Click(object sender, EventArgs e) { System.Environment.Exit(1);//The program exits and returns 1 } #endregion #region form movement private Point mouseOff;//Mouse movement position variable private bool leftFlag;//whether the label is the left button private void Frm_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //Get the value of the variable leftFlag = true; //Marked as true when the left button is pressed; } } private void Frm_MouseMove(object sender, MouseEventArgs e) { if(leftFlag) { Point mouseSet = Control.MousePosition; mouseSet.Offset(mouseOff.X, mouseOff.Y); //Set the position after movement Location = mouseSet; } } private void Frm_MouseUp(object sender, MouseEventArgs e) { if(leftFlag) { leftFlag = false;//Marked as false after releasing the mouse; } } #endregion #region time synchronization private void Timer_Tick(object sender, EventArgs e) { ts_DateTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } #endregion #region desktop loading private void MainWinFrm_Load(object sender, EventArgs e) { timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick + = Timer_Tick!; timer.Enabled = true; } #endregion #region Move mouse coordinates private void MainFrm_Move(object sender, EventArgs e) { // Get the coordinates of the current mouse Point cursorPosition = Cursor.Position; TS_X.Text = cursorPosition.X.ToString(); TS_Y.Text = cursorPosition.Y.ToString(); } #endregion #region Log information private void Loginfo(string log, bool isPass, int item = 0) { Invoke(() => { ListViewItem li_er = new ListViewItem(); li_er.SubItems[0].Text = log; li_er.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); li_er.ForeColor = isPass ? Color.Green : Color.Red; lv_log.Items.Add(li_er); if(item==1) { //this.txt_ScanSn.Enabled = true; //this.Focus(); btn_StartTest.Enabled = false; btn_Restart.Enabled = false; } else if (item == 2)//Start retest { //this.txt_ScanSn.Enabled = false; btn_Restart.Enabled = true; btn_StartTest.Enabled = false; } }); } #endregion private void btn_StartTest_Click_1(object sender, EventArgs e) { btn_StartTest.Enabled = false; this.StartTest();//Start the test } #region Start testing public void StartTest() { //lbl_TestItem.Text = "Start testing all LED indicators with random flash times!!"; //lbl_TestImage.Image = Properties.Resources._1; //Random random = new Random(); //this.randcount = random.Next(1, 5); //this.AllLEDIllumeTest(this.randcount);//Random number lbl_TestItem.Text = "Start the power charging indicator light, random flash times test!!"; lbl_TestImage.Image = Properties.Resources._2; Random random = new Random(); this.randcount = random.Next(1, 5); this.BatteryLedIllumTest(this.randcount);//Random number of power indicator lights foreach (Control control in this.groupBox5.Controls) { if (control is Button) { ((Button)control).Enabled = true; } } } #endregion #region initialization interface private void Winitial(bool IsEnable) { foreach (Control control in this.groupBox5.Controls) { if (control is Button) { ((Button)control).Enabled = IsEnable; } } lbl_TestImage.Image = null; lbl_TestItem.Text = "Power indicator test to be started!!"; lbl_TestResult.Text = "to be tested"; lbl_TestImage.ForeColor = Color.SandyBrown; } #endregion #region Retest private void btn_Restart_Click(object sender, EventArgs e) { this.Winitial(false);//Initialization this.StartTest();//Start the test } #endregion bool isFirst = true; private void btn_num_Click(object sender, EventArgs e) { if(isFirst) { if (((Button)sender).Text == this.randcount.ToString()) { this.lbl_TestResult.ForeColor = Color.Green; this.lbl_TestResult.Text = "PASS"; //lbl_TestItem.Text = "Start the power charging indicator light and randomly flash the test!!"; //lbl_TestImage.Image = Properties.Resources._2; //Random random = new Random(); //this.randcount = random.Next(1, 5); //this.BatteryLedIllumTest(this.randcount);//Random number of power indicator lights lbl_TestItem.Text = "Start all LED indicators, random flash test!!"; lbl_TestImage.Image = Properties.Resources._1; Random random = new Random(); this.randcount = random.Next(1, 5); this.AllLEDIllumeTest(this.randcount);//Random number isFirst = false; } else { this.lbl_TestResult.ForeColor = Color.Red; this.lbl_TestResult.Text = "FAIL"; btn_Restart.Enabled = true; btn_StartTest.Enabled = false; isFirst = true; //this.Loginfo("All LEDs are lit for test, the number of flashes does not match the actual selected sequence number, the test result is FAIL!!", false); this.Loginfo("Power indicator light test, the number of flashes does not match the actual selected serial number, the test result is FAIL!!", false); foreach (Control control in this.groupBox5.Controls) { if (control is Button) { ((Button)control).Enabled = false; } } } } else { if (((Button)sender).Text == this.randcount.ToString()) { this.lbl_TestResult.ForeColor = Color.Green; this.lbl_TestResult.Text = "PASS"; timer1.Enabled = true; } else { this.lbl_TestResult.ForeColor = Color.Red; this.lbl_TestResult.Text = "FAIL"; btn_Restart.Enabled = true; btn_StartTest.Enabled = false; isFirst = true; //this.Loginfo("Power indicator light test, the number of flashes does not match the actual selected sequence number, the test result is FAIL!!", false); this.Loginfo("All LEDs are lit for testing, the number of flashes does not match the actual selected sequence number, the test result is FAIL!!", false); foreach (Control control in this.groupBox5.Controls) { if (control is Button) { ((Button)control).Enabled = false; } } } } } private int index = 5; private void timer1_Tick(object sender, EventArgs e) { lbl_Exit.Visible = true; if (index > 0) { lbl_Exit.Text = index.ToString(); index--; } else { System.Environment.Exit(0); } } } }
UI display: