private void 通道1ToolStripMenuItem_Click(object sender, EventArgs e) { Register.Byte83H = (byte)(Register.Byte83H | 0x02); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); Register.Byte83H = (byte)(Register.Byte83H & 0x7d); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); USB.SendData(Data.OnlyId, StrToHexByte("1D01000a" + "04008103000000029A28" + "C0DEC0DEC0DEC0DEC0DEC0DEC0DEC0DE")); }
private void 开始ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.开始ToolStripMenuItem.Text == "开始") { this.开始ToolStripMenuItem.Text = "停止"; if (USB.MyDeviceList[Data.OnlyId] != null) { CyControlEndPoint CtrlEndPt = null; CtrlEndPt = USB.MyDeviceList[Data.OnlyId].ControlEndPt; if (CtrlEndPt != null) { USB.SendCMD(Data.OnlyId, 0x80, 0x01); USB.SendCMD(Data.OnlyId, 0x80, 0x00); USB.MyDeviceList[Data.OnlyId].Reset(); Register.Byte80H = (byte)(Register.Byte80H | 0x04); USB.SendCMD(Data.OnlyId, 0x80, Register.Byte80H); } FileThread = new SaveFile(); FileThread.FileInit(); FileThread.FileSaveStart(); MyLog.Info("开始读取"); RecvTag = true; ThisCount = 0; LastCount = 0; new Thread(() => { RecvAllUSB(); }).Start(); new Thread(() => { DealWithADFun(); }).Start(); new Thread(() => { DealWithSERFun(); }).Start(); } else { MyLog.Error("设备未连接,请检查接线,打开电源!"); } } else { this.开始ToolStripMenuItem.Text = "开始"; ThisCount = 0; LastCount = 0; RecvTag = false; Thread.Sleep(500); if (FileThread != null) { FileThread.FileClose(); } } }
private void 通道3ToolStripMenuItem_Click(object sender, EventArgs e) { Register.Byte83H = (byte)(Register.Byte83H | 0x08); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); Register.Byte83H = (byte)(Register.Byte83H & 0x77); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); USB.SendData(Data.OnlyId, StrToHexByte("1D030004" + "00304591" + "C0DEC0DEC0DEC0DEC0DEC0DEC0DEC0DE")); Register.Byte83H = (byte)(Register.Byte83H | 0x08); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); Register.Byte83H = (byte)(Register.Byte83H & 0x77); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); USB.SendData(Data.OnlyId, StrToHexByte("1D030004" + "00314431" + "C0DEC0DEC0DEC0DEC0DEC0DEC0DEC0DE")); }
public Form1() { InitializeComponent(); //启动日志 MyLog.richTextBox1 = richTextBox1; MyLog.path = Program.GetStartupPath() + @"LogData\"; MyLog.lines = 50; MyLog.start(); // Create the list of USB devices attached to the CyUSB3.sys driver. USB.usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); //Assign event handlers for device attachment and device removal. USB.usbDevices.DeviceAttached += new EventHandler(UsbDevices_DeviceAttached); USB.usbDevices.DeviceRemoved += new EventHandler(UsbDevices_DeviceRemoved); USB.Init(); }
private void button28_Click(object sender, EventArgs e) { Register.Byte83H = (byte)(Register.Byte83H | 0x01); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); Register.Byte83H = (byte)(Register.Byte83H & 0x7e); USB.SendCMD(Data.OnlyId, 0x83, Register.Byte83H); double V = (double)numericUpDown5.Value; int mazi = (int)((V * 4095) / 10); string value = mazi.ToString("x4"); String Str_Content = "01 06 00 03 " + value.Substring(0, 2) + " " + value.Substring(2, 2); int lenth = (Str_Content.Length) / 2 + 2; if (lenth >= 0) { string crc = Data.CRCCalc(Str_Content).Replace(" ", "").PadLeft(4, '0'); byte[] temp = StrToHexByte("1D00" + lenth.ToString("x4") + Str_Content + crc + "C0DEC0DEC0DEC0DEC0DEC0DEC0DEC0DE"); USB.SendData(Data.OnlyId, temp); } }
private void button24_Click(object sender, EventArgs e) { Register.Byte81H = (byte)(Register.Byte81H & 0x77);//JDQ3关闭 USB.SendCMD(Data.OnlyId, 0x81, Register.Byte81H); }
private void button21_Click(object sender, EventArgs e) { Register.Byte81H = (byte)(Register.Byte81H | 0x08);//JDQ3打开 USB.SendCMD(Data.OnlyId, 0x81, Register.Byte81H); }
private void button9_Click(object sender, EventArgs e) { Register.Byte81H = (byte)(Register.Byte81H | 0x02); //JDQ2打开 Register.Byte81H = (byte)(Register.Byte81H & 0x7e); //JDQ1关闭 USB.SendCMD(Data.OnlyId, 0x81, Register.Byte81H); }