public bool OpenConnection()
        {
            try
            {
                comAddress = Convert.ToByte("FF", 16);
                baudRate   = Convert.ToByte(5);

                powerDbm = Convert.ToByte(_readerProfile.PowerDbm);

                port = 0;
                int openResult;

                openResult = 30;
                //  Cursor = Cursors.WaitCursor;

                comAddress = Convert.ToByte("FF", 16);
                baudRate   = Convert.ToByte(5);
                if (_readerProfile.ComPort == ComPort.Auto)
                {
                    openResult =
                        StaticClassReaderB.AutoOpenComPort(ref port, ref comAddress, baudRate,
                                                           ref comPortIndex); //automatically detects a com port and connects it with the reader
                }
                else
                {
                    comPortIndex = (int)_readerProfile.ComPort;
                    openResult   = StaticClassReaderB.OpenComPort(comPortIndex, ref comAddress, baudRate,
                                                                  ref comPortIndex);
                }
                openComIndex = comPortIndex;

                if (openResult == 0)
                {
                    logger.Info("Opened port {0} to UhfReader18", openComIndex);
                    var result = StaticClassReaderB.SetPowerDbm(ref fComAdr, powerDbm, openComIndex);
                    if (result == 0)
                    {
                        //                SetWorkingMode();
                        return(true);
                    }
                }
                logger.Error("Serial Communication Error or Occupied - result code : {0}", openResult);
                MessageBox.Show("Serial Communication Error or Occupied - result code: " + openResult);
            }
            catch (Exception ex)
            {
                logger.Error("Open connection: {0}, {1}", ex.Message, ex.ToString());
                MessageBox.Show("Serial Communication Error or Occupied - exception message " + ex.Message);
            }

            return(false);
        }