diff -r 597a95926637 -r 5680e56e9b0b FrmMain.cs --- a/FrmMain.cs Wed May 14 18:54:30 2014 +0200 +++ b/FrmMain.cs Wed Feb 11 15:52:53 2015 +0100 @@ -254,23 +254,23 @@ this.fraControlTransfers.SuspendLayout(); this.fraSendAndGetContinuous.SuspendLayout(); this.SuspendLayout(); - // + // // FraBytesReceived - // + // this.FraBytesReceived.BackColor = System.Drawing.SystemColors.Control; this.FraBytesReceived.Controls.Add(this.TxtBytesReceived); this.FraBytesReceived.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FraBytesReceived.ForeColor = System.Drawing.SystemColors.ControlText; - this.FraBytesReceived.Location = new System.Drawing.Point(495, 353); + this.FraBytesReceived.Location = new System.Drawing.Point(658, 353); this.FraBytesReceived.Name = "FraBytesReceived"; this.FraBytesReceived.RightToLeft = System.Windows.Forms.RightToLeft.No; this.FraBytesReceived.Size = new System.Drawing.Size(112, 136); this.FraBytesReceived.TabIndex = 4; this.FraBytesReceived.TabStop = false; this.FraBytesReceived.Text = "Bytes Received"; - // + // // TxtBytesReceived - // + // this.TxtBytesReceived.AcceptsReturn = true; this.TxtBytesReceived.BackColor = System.Drawing.SystemColors.Window; this.TxtBytesReceived.Cursor = System.Windows.Forms.Cursors.IBeam; @@ -283,25 +283,25 @@ this.TxtBytesReceived.RightToLeft = System.Windows.Forms.RightToLeft.No; this.TxtBytesReceived.Size = new System.Drawing.Size(72, 96); this.TxtBytesReceived.TabIndex = 5; - // + // // FraBytesToSend - // + // this.FraBytesToSend.BackColor = System.Drawing.SystemColors.Control; this.FraBytesToSend.Controls.Add(this.ChkAutoincrement); this.FraBytesToSend.Controls.Add(this.CboByte1); this.FraBytesToSend.Controls.Add(this.CboByte0); this.FraBytesToSend.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FraBytesToSend.ForeColor = System.Drawing.SystemColors.ControlText; - this.FraBytesToSend.Location = new System.Drawing.Point(612, 235); + this.FraBytesToSend.Location = new System.Drawing.Point(776, 235); this.FraBytesToSend.Name = "FraBytesToSend"; this.FraBytesToSend.RightToLeft = System.Windows.Forms.RightToLeft.No; this.FraBytesToSend.Size = new System.Drawing.Size(160, 136); this.FraBytesToSend.TabIndex = 1; this.FraBytesToSend.TabStop = false; this.FraBytesToSend.Text = "Bytes to Send"; - // + // // ChkAutoincrement - // + // this.ChkAutoincrement.BackColor = System.Drawing.SystemColors.Control; this.ChkAutoincrement.Cursor = System.Windows.Forms.Cursors.Default; this.ChkAutoincrement.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -313,9 +313,9 @@ this.ChkAutoincrement.TabIndex = 6; this.ChkAutoincrement.Text = "Autoincrement values"; this.ChkAutoincrement.UseVisualStyleBackColor = false; - // + // // CboByte1 - // + // this.CboByte1.BackColor = System.Drawing.SystemColors.Window; this.CboByte1.Cursor = System.Windows.Forms.Cursors.Default; this.CboByte1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -326,9 +326,9 @@ this.CboByte1.RightToLeft = System.Windows.Forms.RightToLeft.No; this.CboByte1.Size = new System.Drawing.Size(101, 22); this.CboByte1.TabIndex = 3; - // + // // CboByte0 - // + // this.CboByte0.BackColor = System.Drawing.SystemColors.Window; this.CboByte0.Cursor = System.Windows.Forms.Cursors.Default; this.CboByte0.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -339,106 +339,105 @@ this.CboByte0.RightToLeft = System.Windows.Forms.RightToLeft.No; this.CboByte0.Size = new System.Drawing.Size(101, 22); this.CboByte0.TabIndex = 2; - // + // // LstResults - // + // this.LstResults.BackColor = System.Drawing.SystemColors.Window; this.LstResults.Cursor = System.Windows.Forms.Cursors.Default; - this.LstResults.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.LstResults.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.LstResults.ForeColor = System.Drawing.SystemColors.WindowText; this.LstResults.HorizontalScrollbar = true; - this.LstResults.ItemHeight = 14; this.LstResults.Location = new System.Drawing.Point(12, 494); this.LstResults.Name = "LstResults"; this.LstResults.RightToLeft = System.Windows.Forms.RightToLeft.No; - this.LstResults.Size = new System.Drawing.Size(760, 256); + this.LstResults.Size = new System.Drawing.Size(916, 251); this.LstResults.TabIndex = 0; - // + // // fraInputReportBufferSize - // + // this.fraInputReportBufferSize.Controls.Add(this.cmdInputReportBufferSize); this.fraInputReportBufferSize.Controls.Add(this.txtInputReportBufferSize); - this.fraInputReportBufferSize.Location = new System.Drawing.Point(623, 44); + this.fraInputReportBufferSize.Location = new System.Drawing.Point(787, 44); this.fraInputReportBufferSize.Name = "fraInputReportBufferSize"; this.fraInputReportBufferSize.Size = new System.Drawing.Size(149, 79); this.fraInputReportBufferSize.TabIndex = 9; this.fraInputReportBufferSize.TabStop = false; this.fraInputReportBufferSize.Text = "Input Report Buffer Size"; - // + // // cmdInputReportBufferSize - // + // this.cmdInputReportBufferSize.Location = new System.Drawing.Point(6, 47); this.cmdInputReportBufferSize.Name = "cmdInputReportBufferSize"; this.cmdInputReportBufferSize.Size = new System.Drawing.Size(136, 26); this.cmdInputReportBufferSize.TabIndex = 1; this.cmdInputReportBufferSize.Text = "Change Buffer Size"; this.cmdInputReportBufferSize.Click += new System.EventHandler(this.cmdInputReportBufferSize_Click); - // + // // txtInputReportBufferSize - // + // this.txtInputReportBufferSize.Location = new System.Drawing.Point(6, 21); this.txtInputReportBufferSize.Name = "txtInputReportBufferSize"; this.txtInputReportBufferSize.Size = new System.Drawing.Size(56, 20); this.txtInputReportBufferSize.TabIndex = 0; - // + // // fraDeviceIdentifiers - // + // this.fraDeviceIdentifiers.Controls.Add(this.txtProductID); this.fraDeviceIdentifiers.Controls.Add(this.lblProductID); this.fraDeviceIdentifiers.Controls.Add(this.txtVendorID); this.fraDeviceIdentifiers.Controls.Add(this.lblVendorID); - this.fraDeviceIdentifiers.Location = new System.Drawing.Point(409, 12); + this.fraDeviceIdentifiers.Location = new System.Drawing.Point(573, 12); this.fraDeviceIdentifiers.Name = "fraDeviceIdentifiers"; this.fraDeviceIdentifiers.Size = new System.Drawing.Size(208, 96); this.fraDeviceIdentifiers.TabIndex = 10; this.fraDeviceIdentifiers.TabStop = false; this.fraDeviceIdentifiers.Text = "Device Identifiers"; - // + // // txtProductID - // + // this.txtProductID.Location = new System.Drawing.Point(120, 56); this.txtProductID.Name = "txtProductID"; this.txtProductID.Size = new System.Drawing.Size(72, 20); this.txtProductID.TabIndex = 3; this.txtProductID.Text = "1299"; this.txtProductID.TextChanged += new System.EventHandler(this.txtProductID_TextChanged); - // + // // lblProductID - // + // this.lblProductID.Location = new System.Drawing.Point(16, 56); this.lblProductID.Name = "lblProductID"; this.lblProductID.Size = new System.Drawing.Size(112, 23); this.lblProductID.TabIndex = 2; this.lblProductID.Text = "Product ID (hex):"; - // + // // txtVendorID - // + // this.txtVendorID.Location = new System.Drawing.Point(120, 24); this.txtVendorID.Name = "txtVendorID"; this.txtVendorID.Size = new System.Drawing.Size(72, 20); this.txtVendorID.TabIndex = 1; this.txtVendorID.Text = "0925"; this.txtVendorID.TextChanged += new System.EventHandler(this.txtVendorID_TextChanged); - // + // // lblVendorID - // + // this.lblVendorID.Location = new System.Drawing.Point(16, 24); this.lblVendorID.Name = "lblVendorID"; this.lblVendorID.Size = new System.Drawing.Size(112, 23); this.lblVendorID.TabIndex = 0; this.lblVendorID.Text = "Vendor ID (hex):"; - // + // // cmdFindDevice - // - this.cmdFindDevice.Location = new System.Drawing.Point(636, 12); + // + this.cmdFindDevice.Location = new System.Drawing.Point(800, 12); this.cmdFindDevice.Name = "cmdFindDevice"; this.cmdFindDevice.Size = new System.Drawing.Size(136, 26); this.cmdFindDevice.TabIndex = 11; this.cmdFindDevice.Text = "Find My Device"; this.cmdFindDevice.Click += new System.EventHandler(this.cmdFindDevice_Click); - // + // // cmdSendOutputReportInterrupt - // + // this.cmdSendOutputReportInterrupt.Location = new System.Drawing.Point(21, 27); this.cmdSendOutputReportInterrupt.Name = "cmdSendOutputReportInterrupt"; this.cmdSendOutputReportInterrupt.Size = new System.Drawing.Size(118, 26); @@ -446,9 +445,9 @@ this.cmdSendOutputReportInterrupt.Text = "Send Output Report"; this.cmdSendOutputReportInterrupt.UseVisualStyleBackColor = true; this.cmdSendOutputReportInterrupt.Click += new System.EventHandler(this.cmdSendOutputReportInterrupt_Click); - // + // // cmdGetInputReportInterrupt - // + // this.cmdGetInputReportInterrupt.Location = new System.Drawing.Point(21, 60); this.cmdGetInputReportInterrupt.Name = "cmdGetInputReportInterrupt"; this.cmdGetInputReportInterrupt.Size = new System.Drawing.Size(118, 26); @@ -456,24 +455,24 @@ this.cmdGetInputReportInterrupt.Text = "Get Input Report"; this.cmdGetInputReportInterrupt.UseVisualStyleBackColor = true; this.cmdGetInputReportInterrupt.Click += new System.EventHandler(this.cmdGetInputReportInterrupt_Click); - // + // // fraInterruptTransfers - // + // this.fraInterruptTransfers.BackColor = System.Drawing.SystemColors.Control; this.fraInterruptTransfers.Controls.Add(this.cmdSendOutputReportInterrupt); this.fraInterruptTransfers.Controls.Add(this.cmdGetInputReportInterrupt); this.fraInterruptTransfers.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.fraInterruptTransfers.ForeColor = System.Drawing.SystemColors.ControlText; - this.fraInterruptTransfers.Location = new System.Drawing.Point(338, 129); + this.fraInterruptTransfers.Location = new System.Drawing.Point(502, 129); this.fraInterruptTransfers.Name = "fraInterruptTransfers"; this.fraInterruptTransfers.RightToLeft = System.Windows.Forms.RightToLeft.No; this.fraInterruptTransfers.Size = new System.Drawing.Size(151, 100); this.fraInterruptTransfers.TabIndex = 14; this.fraInterruptTransfers.TabStop = false; this.fraInterruptTransfers.Text = "Interrupt Transfers"; - // + // // cmdPeriodicTransfers - // + // this.cmdPeriodicTransfers.Location = new System.Drawing.Point(153, 36); this.cmdPeriodicTransfers.Name = "cmdPeriodicTransfers"; this.cmdPeriodicTransfers.Size = new System.Drawing.Size(118, 26); @@ -481,9 +480,9 @@ this.cmdPeriodicTransfers.Text = "Start"; this.cmdPeriodicTransfers.UseVisualStyleBackColor = true; this.cmdPeriodicTransfers.Click += new System.EventHandler(this.cmdPeriodicTransfers_Click); - // + // // cmdSendOutputReportControl - // + // this.cmdSendOutputReportControl.Location = new System.Drawing.Point(10, 27); this.cmdSendOutputReportControl.Name = "cmdSendOutputReportControl"; this.cmdSendOutputReportControl.Size = new System.Drawing.Size(118, 26); @@ -491,9 +490,9 @@ this.cmdSendOutputReportControl.Text = "Send Output Report"; this.cmdSendOutputReportControl.UseVisualStyleBackColor = true; this.cmdSendOutputReportControl.Click += new System.EventHandler(this.cmdSendOutputReportControl_Click); - // + // // cmdGetInputReportControl - // + // this.cmdGetInputReportControl.Location = new System.Drawing.Point(10, 60); this.cmdGetInputReportControl.Name = "cmdGetInputReportControl"; this.cmdGetInputReportControl.Size = new System.Drawing.Size(118, 26); @@ -501,9 +500,9 @@ this.cmdGetInputReportControl.Text = "Get Input Report"; this.cmdGetInputReportControl.UseVisualStyleBackColor = true; this.cmdGetInputReportControl.Click += new System.EventHandler(this.cmdGetInputReportControl_Click); - // + // // fraControlTransfers - // + // this.fraControlTransfers.BackColor = System.Drawing.SystemColors.Control; this.fraControlTransfers.Controls.Add(this.cmdGetFeatureReport); this.fraControlTransfers.Controls.Add(this.cmdSendFeatureReport); @@ -511,16 +510,16 @@ this.fraControlTransfers.Controls.Add(this.cmdGetInputReportControl); this.fraControlTransfers.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.fraControlTransfers.ForeColor = System.Drawing.SystemColors.ControlText; - this.fraControlTransfers.Location = new System.Drawing.Point(495, 129); + this.fraControlTransfers.Location = new System.Drawing.Point(659, 129); this.fraControlTransfers.Name = "fraControlTransfers"; this.fraControlTransfers.RightToLeft = System.Windows.Forms.RightToLeft.No; this.fraControlTransfers.Size = new System.Drawing.Size(277, 100); this.fraControlTransfers.TabIndex = 15; this.fraControlTransfers.TabStop = false; this.fraControlTransfers.Text = "Control Transfers"; - // + // // cmdGetFeatureReport - // + // this.cmdGetFeatureReport.Location = new System.Drawing.Point(141, 60); this.cmdGetFeatureReport.Name = "cmdGetFeatureReport"; this.cmdGetFeatureReport.Size = new System.Drawing.Size(118, 26); @@ -528,9 +527,9 @@ this.cmdGetFeatureReport.Text = "Get Feature Report"; this.cmdGetFeatureReport.UseVisualStyleBackColor = true; this.cmdGetFeatureReport.Click += new System.EventHandler(this.cmdGetFeatureReport_Click); - // + // // cmdSendFeatureReport - // + // this.cmdSendFeatureReport.Location = new System.Drawing.Point(141, 27); this.cmdSendFeatureReport.Name = "cmdSendFeatureReport"; this.cmdSendFeatureReport.Size = new System.Drawing.Size(118, 26); @@ -538,9 +537,9 @@ this.cmdSendFeatureReport.Text = "Send Feature Report"; this.cmdSendFeatureReport.UseVisualStyleBackColor = true; this.cmdSendFeatureReport.Click += new System.EventHandler(this.cmdSendFeatureReport_Click); - // + // // fraSendAndGetContinuous - // + // this.fraSendAndGetContinuous.BackColor = System.Drawing.SystemColors.Control; this.fraSendAndGetContinuous.Controls.Add(this.radFeature); this.fraSendAndGetContinuous.Controls.Add(this.radInputOutputControl); @@ -548,16 +547,16 @@ this.fraSendAndGetContinuous.Controls.Add(this.cmdPeriodicTransfers); this.fraSendAndGetContinuous.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.fraSendAndGetContinuous.ForeColor = System.Drawing.SystemColors.ControlText; - this.fraSendAndGetContinuous.Location = new System.Drawing.Point(311, 235); + this.fraSendAndGetContinuous.Location = new System.Drawing.Point(475, 235); this.fraSendAndGetContinuous.Name = "fraSendAndGetContinuous"; this.fraSendAndGetContinuous.RightToLeft = System.Windows.Forms.RightToLeft.No; this.fraSendAndGetContinuous.Size = new System.Drawing.Size(295, 112); this.fraSendAndGetContinuous.TabIndex = 17; this.fraSendAndGetContinuous.TabStop = false; this.fraSendAndGetContinuous.Text = "Send and Get Continuous"; - // + // // radFeature - // + // this.radFeature.AutoSize = true; this.radFeature.Location = new System.Drawing.Point(17, 76); this.radFeature.Name = "radFeature"; @@ -567,9 +566,9 @@ this.radFeature.Text = "Feature"; this.radFeature.UseVisualStyleBackColor = true; this.radFeature.CheckedChanged += new System.EventHandler(this.radFeature_CheckedChanged); - // + // // radInputOutputControl - // + // this.radInputOutputControl.AutoSize = true; this.radInputOutputControl.Location = new System.Drawing.Point(17, 52); this.radInputOutputControl.Name = "radInputOutputControl"; @@ -579,9 +578,9 @@ this.radInputOutputControl.Text = "Input Output Control"; this.radInputOutputControl.UseVisualStyleBackColor = true; this.radInputOutputControl.CheckedChanged += new System.EventHandler(this.radInputOutputControl_CheckedChanged); - // + // // radInputOutputInterrupt - // + // this.radInputOutputInterrupt.AutoSize = true; this.radInputOutputInterrupt.Location = new System.Drawing.Point(17, 28); this.radInputOutputInterrupt.Name = "radInputOutputInterrupt"; @@ -591,18 +590,18 @@ this.radInputOutputInterrupt.Text = "Input Output Interrupt"; this.radInputOutputInterrupt.UseVisualStyleBackColor = true; this.radInputOutputInterrupt.CheckedChanged += new System.EventHandler(this.radInputOutputInterrupt_CheckedChanged); - // + // // treeViewDevices - // + // this.treeViewDevices.Location = new System.Drawing.Point(12, 12); this.treeViewDevices.Name = "treeViewDevices"; - this.treeViewDevices.Size = new System.Drawing.Size(284, 461); + this.treeViewDevices.Size = new System.Drawing.Size(457, 461); this.treeViewDevices.TabIndex = 18; this.treeViewDevices.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewDevices_AfterSelect); - // + // // FrmMain - // - this.ClientSize = new System.Drawing.Size(784, 756); + // + this.ClientSize = new System.Drawing.Size(940, 756); this.Controls.Add(this.treeViewDevices); this.Controls.Add(this.fraSendAndGetContinuous); this.Controls.Add(this.fraControlTransfers); @@ -1349,23 +1348,36 @@ // Display the report data received in the form's list box. LstResults.Items.Add(" Report ID: " + String.Format("{0:X2} ", buffer[0])); + LstResults.Items.Add(" Report Data Size: " + (buffer.Length-1)); //Exclude one byte for the report ID LstResults.Items.Add(" Report Data:"); TxtBytesReceived.Text = ""; + String byteString = ""; + for (count = 1; count <= buffer.Length - 1; count++) { // Display bytes as 2-character Hex strings. - String byteValue = String.Format("{0:X2} ", buffer[count]); + byteString += String.Format(" {0:X2} ", buffer[count]); - LstResults.Items.Add(" " + byteValue); + if (count % 16 == 0) + { + //Add a line to our list box every 16 bytes + LstResults.Items.Add(byteString); + byteString = ""; + } + + // Display the received bytes in the text box. + //TxtBytesReceived.SelectionStart = TxtBytesReceived.Text.Length; + //TxtBytesReceived.SelectedText = byteValue + Environment.NewLine; + } - TxtBytesReceived.SelectionStart = TxtBytesReceived.Text.Length; - TxtBytesReceived.SelectedText = byteValue + Environment.NewLine; - } + //Add the rests of our data + LstResults.Items.Add(byteString); + ScrollToBottomOfListBox(); } catch (Exception ex) @@ -2318,6 +2330,17 @@ } } + + // + // + public static void Fill(T[] arr, T value) + { + for (int i = 0; i < arr.Length; i++) + { + arr[i] = value; + } + } + /// /// Sends an Output report. /// Assumes report ID = 0. @@ -2353,7 +2376,8 @@ { // Set the size of the Output report buffer. - var outputReportBuffer = new Byte[_myHid.Capabilities.OutputReportByteLength]; + Byte[] outputReportBuffer = new Byte[_myHid.Capabilities.OutputReportByteLength]; + Fill(outputReportBuffer,0); // Store the report ID in the first byte of the buffer: @@ -2369,6 +2393,18 @@ outputReportBuffer[2] = Convert.ToByte(CboByte1.SelectedIndex); } + + //Futaba GP1212A01A + //Clear screen + outputReportBuffer[0] = 0; //Report ID + outputReportBuffer[1] = 4; //Size of report, as per Futaba specs + outputReportBuffer[2] = 0x1B; //Clear screen code + outputReportBuffer[3] = 0x5B; + outputReportBuffer[4] = 0x32; + outputReportBuffer[5] = 0x4A; + + + // Write a report. Boolean success;