Beispiel #1
0
        private byte[] BuildSelectRcpPacket()
        {
            ByteBuilder bb = new ByteBuilder();
            int         discard;

            byte[] param = new byte[7];

            param[0] = (byte)
                       ((comboBoxSelTarget.SelectedIndex << 5)
                        + (comboBoxSelAction.SelectedIndex << 2)
                        + (comboBoxSelMemBank.SelectedIndex));
            param[1] = 0;
            param[2] = 0;
            param[3] = (byte)((Convert.ToUInt16(tbSelPointer.Text, 16) & 0xFF00) >> 8);
            param[4] = (byte)((Convert.ToUInt16(tbSelPointer.Text, 16) & 0x00FF));
            param[5] = byte.Parse(tbSelLength.Text);
            param[6] = 0;

            bb.Append(param);

            byte[] mask = HexEncoding.GetBytes(tbSelMask.Text, out discard);
            Array.Resize(ref mask, ((param[5] + 7) / 8));

            if (mask.Length > 0)
            {
                bb.Append(mask);
            }

            return(bb.GetByteArray());
        }
        private void SetFrequncyHopppingChannelTable(byte[] data)
        {
            int size = data[5];

            if (size > data.Length - 9)
            {
                return;
            }

            ByteBuilder ba = new ByteBuilder();

            for (int i = 6; i < size + 6; i++)
            {
                ba.Append(data[i]);
            }

            formChannelTable.SetChannel(ba.GetByteArray());

            if (formChannelTable.isDisplayed)
            {
            }
            else
            {
                formChannelTable.ShowDialog();
            }
        }
Beispiel #3
0
        private byte[] BuildSendLine(int address)
        {
            ByteBuilder bb = new ByteBuilder();

            bb.Append((byte)RcpProtocol.PREAMBLE);
            bb.Append((byte)'W');
            bb.Append((byte)(address >> 8));
            bb.Append((byte)(address & 0x00FF));

            for (int i = 0; i < 0x10; i++)
            {
                bb.Append(rawCode[address + i]);
            }

            bb.Append((byte)RcpProtocol.ENDMARK);
            bb.Append(CRCCalculator.Cal_CRC16(bb.GetByteArray()));

            return(bb.GetByteArray());
        }
Beispiel #4
0
        private byte[] BuildSelectRcpPacket(string target)
        {
            ByteBuilder bb = new ByteBuilder();

            string[] temp = new string[0];

            if (target != null)
            {
                temp = target.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            }

            byte[] mask = new byte[0];

            if (target != null)
            {
                mask = new byte[temp.Length];

                for (int i = 0; i < mask.Length; i++)
                {
                    mask[i] = Convert.ToByte(temp[i], 16);
                }
            }

            byte[] param = new byte[7];

            param[0] = 0x01;    // Bank : EPC
            param[1] = 0x00;
            param[2] = 0x00;
            param[3] = 0x00;
            param[4] = 0x20;    // Pointer : head of EPC
            param[5] = Convert.ToByte(temp.Length << 3);
            param[6] = 0;

            bb.Append(param);

            bb.Append(mask);

            return(bb.GetByteArray());
        }
        private void SetModulePowerTable(byte[] data)
        {
            int size = data[5];

            if (size > data.Length - 9)
            {
                return;
            }

            refModulePwr = new UInt16[(size >> 1)];

            ByteBuilder ba = new ByteBuilder();

            for (int i = 0; i < (size >> 1); i++)
            {
                refModulePwr[i]  = Convert.ToUInt16(data[(i * 2) + 6] << 8);
                refModulePwr[i] += data[i * 2 + 7];
            }

            FormPowerLevellTable formPowerLevelTable = new FormPowerLevellTable();

            formPowerLevelTable.SetPowerLevel(refModulePwr, aCalOffsetTbl);

            if (formPowerLevelTable.ShowDialog() == DialogResult.OK)
            {
                refModulePwr = (UInt16[])formPowerLevelTable.APower.Clone();

                ba.Clear();
                ba.Append((byte)(refModulePwr.Length * 2));

                for (int i = 0; i < refModulePwr.Length; i++)
                {
                    ba.Append((UInt16)refModulePwr[i]);
                }

                if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_MODULE_PWR_TBL, ba.GetByteArray())))
                {
                }
            }
        }
        private void buttonSetTxGainOffset_Click(object sender, EventArgs e)
        {
            try
            {
                ByteBuilder bb = new ByteBuilder();

                if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_OFFSET, bb.GetByteArray())))
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        private void buttonUpdateTable_Click(object sender, EventArgs e)
        {
            m_aChannel = new byte[this.listViewEx1.Items.Count];

            for (int i = 0; i < this.listViewEx1.Items.Count; i++)
            {
                try
                {
                    m_aChannel[i] = byte.Parse(this.listViewEx1.Items[i].SubItems[1].Text);
                }
                catch
                {
                }
            }

            ByteBuilder bb = new ByteBuilder();

            bb.Clear();

            bb.Append((byte)this.GetChannelTable().Length);
            bb.Append(this.GetChannelTable());

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_HOPPING_TBL, bb.GetByteArray())))
            {
            }
            bb.Clear();
        }
        //public event RegistryUpdate_Result registryUpdate_result;

        private void button_UpdateNow_Click(object sender, EventArgs e)
        {
            //this.registryUpdate_result(true);

            ByteBuilder bb = new ByteBuilder();

            bb.Append(0x01);

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_UPDATE_FLASH, bb.GetByteArray())))
            {
            }

            this.Close();
        }
        private void btnDownLoad_Click(object sender, EventArgs e)
        {
            byte[] msg = Encoding.ASCII.GetBytes(txtWifi.Text + (chkD.Checked ? '\n'.ToString() : "") + (chkA.Checked ? '\r'.ToString() : ""));

            ByteBuilder bb = new ByteBuilder();

            bb.Append((byte)2);
            bb.Append(msg);
            if (!SystemPub.ADRcp.SendBytePkt(SystemPub.ADRcp.BuildCmdPacketByte(PassiveRcp.RCP_MSG_SENIOR_SET, PassiveRcp.RCP_CMD_WIFI_DOWNLOAD, bb.GetByteArray())))
            {
            }
        }
Beispiel #10
0
        private void button_WriteModulePowerTable_Click(object sender, EventArgs e)
        {
            ByteBuilder bb = new ByteBuilder();

            for (int i = 0; i < temp_Estimate.Length; i++)
            {
                bb.Append(Convert.ToByte((temp_Estimate[i] >> 8) & 0xff));
                bb.Append(Convert.ToByte(temp_Estimate[i] & 0xff));
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_MODULE_TABLE, bb.GetByteArray())))
            {
            }
        }
        private void buttonFhssLbt_Click(object sender, EventArgs e)
        {
            ByteBuilder bb = new ByteBuilder();

            UInt16 read_time;
            UInt16 idle_time;
            UInt16 sense_time;
            float  rf_level;

            try
            {
                read_time  = UInt16.Parse(tbReadTime.Text);
                idle_time  = UInt16.Parse(tbIdleTime.Text);
                sense_time = UInt16.Parse(tbCwSenseTime.Text);
                rf_level   = float.Parse(tbLbtRfLevel.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bb.Append(read_time);
            bb.Append(idle_time);
            bb.Append(sense_time);
            bb.Append((UInt16)(rf_level * 10));

            if (cbFH.Checked)
            {
                bb.Append((byte)1);
                bb.Append((byte)0);
            }

            if (cbLBT.Checked)
            {
                bb.Append((byte)0);
                bb.Append((byte)1);
            }

            if (cbFHwithLBT.Checked)
            {
                bb.Append((byte)2);
                bb.Append((byte)1);
            }

            if (cbLBTwithFH.Checked)
            {
                bb.Append((byte)1);
                bb.Append((byte)2);
            }

            if (cbFH.Checked == false && cbLBT.Checked == false && cbFHwithLBT.Checked == false && cbLBTwithFH.Checked == false)
            {
                bb.Append((byte)0);
                bb.Append((byte)0);
                bb.Append((byte)0);
            }

            //if (cbCW.Checked) bb.Append((byte)1);
            else
            {
                bb.Append((byte)0);
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_FH_LBT, bb.GetByteArray())))
            {
            }
        }
        private void regUpdate()
        {
            ByteBuilder bb = new ByteBuilder();

            bb.Append(0x01);

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_UPDATE_FLASH, bb.GetByteArray())))
            {
            }
        }
        private void fb_param_set(string[] fb_parm)
        {
            ByteBuilder bb = new ByteBuilder();

            byte txLPF;
            byte fb_res1;
            byte fb_res2;


            try
            {
                txLPF   = Convert.ToByte(fb_parm[0]);
                fb_res1 = Convert.ToByte(fb_parm[1]);
                fb_res2 = Convert.ToByte(fb_parm[2]);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bb.Append(txLPF);
            bb.Append(fb_res1);
            bb.Append(fb_res2);


            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_FB_PARAM, bb.GetByteArray())))
            {
            }
        }
        public bool compare_DynamicRange(double min_range, double max_range)
        {
            ByteBuilder bb = new ByteBuilder();

            UInt16 minRange_power = 100;
            UInt16 maxRange_power = 200;

            bool dynmic_range_Flag = false;


            //  double margine_power = Convert.ToDouble(cmd_data[3]);

            double ReadData = 0f;

            bb.Append((UInt16)(minRange_power));
            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_PWR, bb.GetByteArray())))
            {
            }
            bb.Clear();

            WaitForReceived();

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CW, new byte[] { 0xFF })))
            {
            }

            WaitForReceived();

            System.Threading.Thread.Sleep(500);

            DirectWrite(m_Spectrum1, "CALC:MARK1:MAX");
            System.Threading.Thread.Sleep(100);

            DirectWrite(m_Spectrum1, "CALC:MARK1:Y?");
            System.Threading.Thread.Sleep(100);

            DirectRead(m_Spectrum1, ref temp, "0");


            ReadData = temp;//(double)ioSpectrumAnalyzer.ReadNumber(IEEEASCIIType.ASCIIType_R8, true);

            System.Threading.Thread.Sleep(100);

            if (ReadData <= min_range && (ReadData > (min_range - 2)))
            {
                dynmic_range_Flag = true;
                __gRange_minVal   = ReadData;
            }
            else
            {
                dynmic_range_Flag = false;
                return(dynmic_range_Flag);
            }

            //System.Threading.Thread.Sleep(1000);

            bb.Append((UInt16)(maxRange_power));
            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_PWR, bb.GetByteArray())))
            {
            }
            bb.Clear();

            WaitForReceived();

            System.Threading.Thread.Sleep(500);

            DirectWrite(m_Spectrum1, "CALC:MARK1:MAX");
            System.Threading.Thread.Sleep(100);

            DirectWrite(m_Spectrum1, "CALC:MARK1:Y?");
            System.Threading.Thread.Sleep(100);

            DirectRead(m_Spectrum1, ref temp, "0");


            ReadData = temp;//(double)ioSpectrumAnalyzer.ReadNumber(IEEEASCIIType.ASCIIType_R8, true);
            System.Threading.Thread.Sleep(100);

            // DisplayMsgString("max power :" + Convert.ToString(ReadData) + "\r\n");


            if (ReadData > (max_range + 0.8f))
            {
                dynmic_range_Flag = true;
                __gRange_maxVal   = ReadData;
            }
            else
            {
                dynmic_range_Flag = false;
                return(dynmic_range_Flag);
            }


            return(dynmic_range_Flag);
        }
        public void cal_confirmation()
        {
            ByteBuilder bb = new ByteBuilder();

            float  power    = 0f;
            double ReadData = 0;
            byte   region   = 0x11;

            byte[] param       = new byte[2];
            double ConfirmData = 0;

            if (RcpProtocol.Instance.m_bRcpReceivedPacket != false)
            {
                RcpProtocol.Instance.m_bRcpReceivedPacket = false;
            }

            //switch ((string)cbRegion.SelectedItem)
            switch (regionVal)
            {
            case 0:    //"Korea":// Korea (0x11)
                region   = 0x11;
                param[0] = 0x14;
                param[1] = 0;
                break;

            case 1:    //""US":// US (0x21)
                region   = 0x21;
                param[0] = 1;
                param[1] = 0;
                break;

            case 2:    //""US2":// US2 (0x22)
                region   = 0x22;
                param[0] = 0x19;
                param[1] = 0;
                break;

            case 3:    //""Europe":// Europe (0x31)
                region   = 0x31;
                param[0] = 0x0A;
                param[1] = 0;
                break;

            case 4:    //""Japan":// Japan (0x41)
                region   = 0x41;
                param[0] = 0x18;
                param[1] = 0;
                break;

            case 5:    //""China1":// China1 (0x51)
                region   = 0x51;
                param[0] = 1;
                param[1] = 0;
                break;

            case 6:    //""China2":// China2 (0x52)
                region   = 0x52;
                param[0] = 1;
                param[1] = 0;
                break;
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_REGION, new byte[] { region })))
            {
                return;
            }

            WaitForReceived();

            // System.Threading.Thread.Sleep(100);

            if (param[1] < 10)
            {
                param[1] = (byte)((byte)param[1] * ((byte)10));
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CH, param)))
            {
            }

            WaitForReceived();

            if (!InvokeRequired)
            {
                power = (float)(Convert.ToDouble(this.comboBox_StartPosition.Text));
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                //power = (float)(Convert.ToDouble((string)this.comboBox_StartPosition.SelectedItem));
                power = (float)(Convert.ToDouble(this.comboBox_StartPosition.Text));
            }));


            bb.Append((UInt16)((power) * 10));

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_MODULE_TX_PWR, bb.GetByteArray())))
            {
            }
            bb.Clear();
            WaitForReceived();

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CW, new byte[] { 0xFF })))
            {
            }

            WaitForReceived();

            System.Threading.Thread.Sleep(1000);

            DirectWrite(m_Spectrum1, "CALC:MARK1:MAX");
            System.Threading.Thread.Sleep(100);

            DirectWrite(m_Spectrum1, "CALC:MARK1:Y?");
            System.Threading.Thread.Sleep(100);

            DirectRead(m_Spectrum1, ref temp, "0");

            if (!InvokeRequired)
            {
                ConfirmData = Convert.ToDouble(comboBox_StartPosition.Text);
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                ConfirmData = Convert.ToDouble(comboBox_StartPosition.Text);
            }));



            ReadData = temp;//(double)ioSpectrumAnalyzer.ReadNumber(IEEEASCIIType.ASCIIType_R8, true);

            if (ReadData <= ConfirmData + 1 && ReadData >= ConfirmData - 0.5f)
            {
                if (!InvokeRequired)
                {
                    lb_calConfirm.Text      = "Pass";
                    lb_calConfirm.ForeColor = Color.Blue;
                    button_CP_TBL.Enabled   = true;

                    // return;
                }

                this.Invoke(new MethodInvoker(delegate()
                {
                    lb_calConfirm.Text      = "Pass";
                    lb_calConfirm.ForeColor = Color.Blue;
                    button_CP_TBL.Enabled   = true;
                }));
            }
            else
            {
                if (!InvokeRequired)
                {
                    lb_calConfirm.Text      = "Fail";
                    lb_calConfirm.ForeColor = Color.Red;
                    button_CP_TBL.Enabled   = true;

                    // return;
                }

                this.Invoke(new MethodInvoker(delegate()
                {
                    lb_calConfirm.Text      = "Fail";
                    lb_calConfirm.ForeColor = Color.Red;
                    button_CP_TBL.Enabled   = true;
                }));
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CW, new byte[] { 0x00 })))
            {
            }
        }
        private void StartCalibration()
        {
            ByteBuilder bb = new ByteBuilder();

            UInt16 power         = 200;
            double ReadData      = 0;
            double StartPosition = 0;
            int    tblSize       = 0;

            if (RcpProtocol.Instance.m_bRcpReceivedPacket != false)
            {
                RcpProtocol.Instance.m_bRcpReceivedPacket = false;
            }

            if (!InvokeRequired)
            {
                lb_calConfirm.Text      = "Processing";
                lb_calConfirm.ForeColor = Color.Blue;
                // return;
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                lb_calConfirm.Text      = "Processing";
                lb_calConfirm.ForeColor = Color.Blue;
            }));



            if (!InvokeRequired)
            {
                StartPosition = Convert.ToDouble(comboBox_StartPosition.Text);
                // return;
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                StartPosition = Convert.ToDouble(comboBox_StartPosition.Text);
            }));


            int Range = 0;

            if (!InvokeRequired)
            {
                Range = Convert.ToInt32(comboBox_Range.Text);
                // return;
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                Range = Convert.ToInt32(comboBox_Range.Text);
            }));


            equipment_Setup();

            reader_operate();
            System.Threading.Thread.Sleep(100);


            for (int i = 0; i < MatchedOffset.Length; i++)
            {
                if (StartPosition == Range)
                {
                    tblSize = i + 1;
                }

                while (StartPosition >= Range)
                {
                    DirectWrite(m_Spectrum1, "CALC:MARK1:MAX");
                    System.Threading.Thread.Sleep(100);

                    DirectWrite(m_Spectrum1, "CALC:MARK1:Y?");
                    System.Threading.Thread.Sleep(100);

                    DirectRead(m_Spectrum1, ref temp, "0");


                    ReadData = temp;//(double)ioSpectrumAnalyzer.ReadNumber(IEEEASCIIType.ASCIIType_R8, true);
                    System.Threading.Thread.Sleep(100);


                    if (StartPosition < ReadData)
                    {
                        bb.Append((UInt16)(power--));
                        if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_PWR, bb.GetByteArray())))
                        {
                        }
                        bb.Clear();
                        //System.Threading.Thread.Sleep(100);
                        bb.Clear();

                        WaitForReceived();
                    }
                    else
                    {
                        // MatchedOffset[j] = (power - 200f) / 10;
                        MatchedOffset[i] = power;
                        break;
                    }

                    if (power < 100)
                    {
                        break;
                    }
                }

                StartPosition -= 0.5f;
            }

            if (!InvokeRequired)
            {
                StartPosition = Convert.ToDouble(comboBox_StartPosition.Text);
            }
            this.Invoke(new MethodInvoker(delegate()
            {
                StartPosition = Convert.ToDouble(comboBox_StartPosition.Text);
            }));


            for (int i = 0; i < MatchedOffset.Length; i++)
            {
                ListViewItem lvi = new ListViewItem(Convert.ToString(StartPosition - (0.5 * i)));
                if (!InvokeRequired)
                {
                    lvi.SubItems.Add(Convert.ToString(MatchedOffset[i]));
                    this.listViewEx2.Items.Add(lvi);
                }
                this.Invoke(new MethodInvoker(delegate()
                {
                    lvi.SubItems.Add(Convert.ToString(MatchedOffset[i]));
                    this.listViewEx2.Items.Add(lvi);
                }));
            }


            //////////Reset / Registry Update /////////////

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_CTL_RESET, null)))
            {
            }
            WaitForReceived();
            //  System.Threading.Thread.Sleep(100);


            System.Threading.Thread.Sleep(500);

            /////////Table Update//////

            // DisplayMsgString(Convert.ToString(tblSize));

            refModulePwr = new UInt16[tblSize];

            for (int j = 0; j < tblSize; j++)
            {
                refModulePwr[j] = MatchedOffset[j];
            }

            bb.Append((byte)(refModulePwr.Length * 2));

            for (int i = 0; i < refModulePwr.Length; i++)
            {
                bb.Append((UInt16)refModulePwr[i]);
            }

            if (!RcpProtocol.Instance.SendBytePkt
                    (RcpProtocol.Instance.BuildCmdPacketByte
                        (RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_MODULE_PWR_TBL, bb.GetByteArray())))
            {
            }

            bb.Clear();

            WaitForReceived();
            //   System.Threading.Thread.Sleep(100);

            bb.Append(0x01);

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_UPDATE_FLASH, bb.GetByteArray())))
            {
            }

            WaitForReceived();
            //   System.Threading.Thread.Sleep(100);

            // float power = 0f;
            ///////////Calibration Confirmation////////////////////
            System.Threading.Thread.Sleep(500);
            cal_confirmation();
        }
        private void buttonSetTxPwr_Click(object sender, EventArgs e)
        {
            ByteBuilder bb    = new ByteBuilder();
            float       power = 0f;

            try
            {
                power = (float)Convert.ToDouble((string)cbTxPwr.SelectedItem);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            bb.Append((UInt16)(power * 10));

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_MODULE_TX_PWR, bb.GetByteArray())))
            {
            }
        }
        private void reader_operate()
        {
            byte region = 0x11;

            byte[]      param = new byte[2];
            UInt16      power = 200;
            ByteBuilder bb    = new ByteBuilder();



            if (!InvokeRequired)
            {
                regionVal = this.cb_region.SelectedIndex;
                // return;
            }

            this.Invoke(new MethodInvoker(delegate()
            {
                regionVal = this.cb_region.SelectedIndex;
            }));


            if (RcpProtocol.Instance.m_bRcpReceivedPacket != false)
            {
                RcpProtocol.Instance.m_bRcpReceivedPacket = false;
            }

            //switch ((string)cbRegion.SelectedItem)
            switch (regionVal)
            {
            case 0:    //"Korea":// Korea (0x11)
                region   = 0x11;
                param[0] = 0x14;
                param[1] = 0;
                break;

            case 1:    //""US":// US (0x21)
                region   = 0x21;
                param[0] = 1;
                param[1] = 0;
                break;

            case 2:    //""US2":// US2 (0x22)
                region   = 0x22;
                param[0] = 0x19;
                param[1] = 0;
                break;

            case 3:    //""Europe":// Europe (0x31)
                region   = 0x31;
                param[0] = 0x0A;
                param[1] = 0;
                break;

            case 4:    //""Japan":// Japan (0x41)
                region   = 0x41;
                param[0] = 0x18;
                param[1] = 0;
                break;

            case 5:    //""China1":// China1 (0x51)
                region   = 0x51;
                param[0] = 1;
                param[1] = 0;
                break;

            case 6:    //""China2":// China2 (0x52)
                region   = 0x52;
                param[0] = 1;
                param[1] = 0;
                break;
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_REGION, new byte[] { region })))
            {
                return;
            }

            WaitForReceived();

            // System.Threading.Thread.Sleep(100);

            if (param[1] < 10)
            {
                param[1] = (byte)((byte)param[1] * ((byte)10));
            }

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CH, param)))
            {
            }

            WaitForReceived();

            bb.Append((UInt16)power);
            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_PWR, bb.GetByteArray())))
            {
            }
            bb.Clear();
            WaitForReceived();
            System.Threading.Thread.Sleep(100);

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_CW, new byte[] { 0xFF })))
            {
            }
            bb.Clear();
            WaitForReceived();
            System.Threading.Thread.Sleep(500);
        }
        private void buttonEepErase_Click(object sender, EventArgs e)
        {
            ByteBuilder bb = new ByteBuilder();

            bb.Append(0xff);

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_ERASE_FLASH, bb.GetByteArray())))
            {
            }
        }
Beispiel #20
0
        public void SetTxPower(float power)
        {
            ByteBuilder bb = new ByteBuilder();

            bb.Append((UInt16)(power * 100));

            if (!RcpProtocol.Instance.SendBytePkt(RcpProtocol.Instance.BuildCmdPacketByte(RcpProtocol.RCP_MSG_CMD, RcpProtocol.RCP_CMD_SET_TX_PWR, bb.GetByteArray())))
            {
            }
        }