Пример #1
0
 private void btn_ReadReg_Click(object sender, EventArgs e)
 {
     myRegOp.RegRead(this.regAddrList);
     myRegOp.UpdateRegSettingSource();
 }
Пример #2
0
        private void btn_Read_Click(object sender, EventArgs e)
        {
            if (regMap == null)
            {
                MessageBox.Show("Pease open excel/proj file first");
                return;
            }

            outputString.Clear();
            //outputString.AppendLine("All register value in hexadecimal format");
            //outputString.AppendLine();
            if (myDongle.IsOpen)
            {
                #region Count is how many registers
                //byte currentRegAddr = startAddr;
                //int finishCount = 0;
                //byte[] regData;
                //while (currentRegAddr <= 0xFF && finishCount < rwCount)
                //{
                //    if (regMap.Contain(currentRegAddr))
                //    {
                //        //currentReg = regMap[currentRegAddr];
                //        regData = new byte[regMap[currentRegAddr].ByteCount];
                //        if (RegRead(currentRegAddr, regData))
                //        {
                //            // print read back register infomation
                //            for (int ixByteCount = 0; ixByteCount < regData.Length; )
                //            {
                //                //outputString.Append(tempReg.ByteValue[ixByteCount].ToString("X2"));
                //                outputString.Append(String.Format("{0}", regData[ixByteCount].ToString("X2")));
                //                if (++ixByteCount < regData.Length)
                //                    outputString.Append("-");
                //            }
                //            outputString.Append("\r\n");
                //            //outputString.Append("\r\n");
                //            finishCount++;
                //        }
                //        else
                //        {
                //            MessageBox.Show(String.Format("No.{0} Register 0x{1} read failed!", finishCount, currentRegAddr));
                //            break;
                //        }
                //    }
                //    currentRegAddr++;
                //}
                #endregion

                #region Count is how many bytes
                byte[] regData = new byte[rwCount];

                if (myRegOp.RegRead(startAddr, regData, true))
                {
                    // print read back register infomation
                    for (int ixByteCount = 0; ixByteCount < regData.Length;)
                    {
                        outputString.Append(String.Format("{0}", regData[ixByteCount].ToString("X2")));
                        if (++ixByteCount % 10 == 0)
                        {
                            outputString.Append("\r\n");
                        }
                        else if (ixByteCount < regData.Length)
                        {
                            outputString.Append("-");
                        }
                    }
                }
                else
                {
                    outputString.Append(String.Format("/* Read failed! */"));
                }
                #endregion
            }
            else
            {
                outputString.Append(String.Format("/* Can't find Dongle! */"));
            }
            this.txt_Display.Text = outputString.ToString();
        }