public bool UpdateSettings(ReaderProfile readerProfile)
        {
            _readerProfile = readerProfile;

            Session = Convert.ToByte((int)_readerProfile.InventorySearchMode);

            if (_readerConnected)
            {
                RWDev.SetRfPower(ref fComAdr, Convert.ToByte(_readerProfile.PowerDbm), frmcomportindex);

                setWorkMode();
            }

            //   byte dminfre = 0, dmaxfre = 0;
            //   int band = 2;
            //   band = 4;
            //  /// dminfre = Convert.ToByte(((band & 3) << 6) | (ComboBox_dminfre.SelectedIndex & 0x3F));
            ////   dmaxfre = Convert.ToByte(((band & 0x0c) << 4) | (ComboBox_dmaxfre.SelectedIndex & 0x3F));
            //   fCmdRet = RWDev.SetRegion(ref fComAdr, dmaxfre, dminfre, frmcomportindex);
            //   if (fCmdRet != 0)
            //   {
            //       string strLog = "Set region failed: " + GetReturnCodeDesc(fCmdRet);
            //       logger.Log(LogLevel.Error,  strLog);
            //       return false;
            //   }
            //   else
            //   {
            //       string strLog = "Set region success ";
            //       return true;

            //   }
            return(true);
        }
        private bool OpenSerial()
        {
            try
            {
                int portNum = (int)_readerProfile.ComPort;
                FrmPortIndex = 0;
                string strException = string.Empty;
                fBaud = Convert.ToByte(3);
                if (fBaud > 2)
                {
                    fBaud = Convert.ToByte(fBaud + 2);
                }
                fComAdr = 255; //Broadcast address to open the device
                fCmdRet = RWDev.OpenComPort(portNum, ref fComAdr, fBaud, ref FrmPortIndex);
                if (fCmdRet != 0)
                {
                    string strLog = "Connect reader failed: " + GetReturnCodeDesc(fCmdRet);
                    // WriteLog(lrtxtLog, strLog, 1);
                    return(false);
                }
                else
                {
                    frmcomportindex = FrmPortIndex;

                    fCmdRet = RWDev.SetRfPower(ref fComAdr, Convert.ToByte(_readerProfile.PowerDbm), frmcomportindex);

                    string strLog = "Connect: "; // + ComboBox_COM.Text + "@" + ComboBox_baud2.Text;
                    //  WriteLog(lrtxtLog, strLog, 0);
                    _readerConnected = true;
                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageBox.Show("Serial Communication Error or Occupied - exception message " + e.Message);
            }

            return(false);
        }
예제 #3
0
        private void buttonSetPower_Click(object sender, EventArgs e)
        {
            byte powerDbm = (byte)comboBoxPower.SelectedIndex;

            try
            {
                ErrorsCatcher.errorName = RWDev.SetRfPower(ref RWDev.comAddress, powerDbm, RWDev.frmComPortIndex);
                if (ErrorsCatcher.errorName != 0)
                {
                    string strLog = "Set power failed " + ErrorsCatcher.GetReturnCodeDesc(ErrorsCatcher.errorName) + Environment.NewLine;
                    richTextBoxLogs.AppendText(strLog);
                    return;
                }
                else
                {
                    string strLog = "Set address success" + Environment.NewLine;
                    richTextBoxLogs.AppendText(strLog);
                }
            }
            catch
            {
                richTextBoxLogs.AppendText("Set power failed!" + Environment.NewLine);
            }
        }