Example #1
0
        private void comboAscii_IndexChanged(object sender, EventArgs e)
        {
            if (!reader.Connected)
            {
                return;
            }

            // before any host command, the scanner event must be disabled !!
            try
            {
                reader.RemoveEventListener(this, FeIscListenerConst.SCANNER_PRT_EVENT);
            }
            catch (Exception)
            {
                // do anything
            }


            // modify the parameter in the memory...
            if (comboAscii.SelectedIndex == 0)
            {
                reader.SetConfigPara(OBID.ReaderConfig.OperatingMode.ScanMode.DataFormat.Format, (byte)0, true); // unformatted hex
            }
            else
            {
                reader.SetConfigPara(OBID.ReaderConfig.OperatingMode.ScanMode.DataFormat.Format, (byte)2, true); // formatted ascii
            }

            try
            {
                // ... and finally write the reader configuration
                reader.ApplyConfiguration(true);
            }
            catch (Exception)
            {
                // do anything
            }

            // enable scanner event
            try
            {
                reader.AddEventListener(this, FeIscListenerConst.SCANNER_PRT_EVENT);
            }
            catch (Exception)
            {
                // do anything
            }
        }
        private void ISOSample_FormClosing(object sender, FormClosingEventArgs e)
        {
            // stop reading
            running = false;

            //remove Events
            fedm.RemoveEventListener(this, FeIscListenerConst.SEND_STRING_EVENT);
            fedm.RemoveEventListener(this, FeIscListenerConst.RECEIVE_STRING_EVENT);

            if (fedm.Connected == true)
            {
                // set Persistence Reset Time in Reader Configuration back to old value
                int back = OBID.Fedm.ERROR_UNSUPPORTED_NAMESPACE;
                try
                {
                    back = fedm.TestConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime);
                }
                catch (Exception ex)
                { // ignore Exception
                }
                // if reader supports this parameter, set it back to old value !
                if (0 == back)
                {
                    try
                    {
                        back = fedm.SetConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime, persistenceResetTime, false);
                        if (back == 1) // return value 1 indicates modified parameter
                        {
                            back = fedm.ApplyConfiguration(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.ToString(), "Error");
                    }
                }
            }

            // close port
            config.Close();
        }
        public ISOHostSample()
        {
            try
            {
                fedm = new FedmIscReader();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "Error");
            }

            //declaration from Thread
            Thread MyThread = new Thread(new ThreadStart(ReadThread));

            fedm.SetTableSize(FedmIscReaderConst.ISO_TABLE, 128);

            config = new PortConnection();
            config.PortConfig(ref fedm);
            DialogResult reponse = config.ShowDialog();


            if (fedm.Connected == true)
            {
                try
                {
                    fedm.ReadCompleteConfiguration(false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.ToString(), "Error");
                }
                // set Persistence Reset Time in Reader Configuration to zero
                // this speeds up inventory cycles
                int back = OBID.Fedm.ERROR_UNSUPPORTED_NAMESPACE;
                try
                {
                    back = fedm.TestConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime);
                }
                catch (Exception ex)
                { // ignore Exception
                }
                // if reader supports this parameter, set it !
                if (0 == back)
                {
                    try
                    {
                        back = fedm.GetConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime, out persistenceResetTime, false);
                        back = fedm.SetConfigPara(OBID.ReaderConfig.Transponder.PersistenceReset.Antenna.No1.PersistenceResetTime, (uint)0, false);
                        if (back == 1) // return value 1 indicates modified parameter
                        {
                            back = fedm.ApplyConfiguration(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.ToString(), "Error");
                    }
                }
            }

            // Init Dialogs Authent
            authmifare_config = new AuthentMifare(this.fedm);
            authmyd_config    = new AuthentMYD(this.fedm);

            if (fedm.Connected == true && reponse == DialogResult.Cancel)
            {
                InitializeComponent();

                //set read Mode
                this.comboBoxMod.SelectedIndex = 1;

                //set bank for UHF
                this.comboBoxBank.SelectedIndex = 3;
                this.comboBoxBank.Enabled       = false;

                // set blockSize
                this.numericUpDownDBS.Minimum   = 1;
                this.numericUpDownDBS.Maximum   = 256;
                this.numericUpDownDBS.Increment = 1;
                this.numericUpDownDBS.Value     = 4;

                // set the number of blocks
                this.numericUpDownDBN.Minimum   = 1;
                this.numericUpDownDBN.Maximum   = 256;
                this.numericUpDownDBN.Increment = 1;
                this.numericUpDownDBN.Value     = 1;

                // set status of Authent Buttons
                this.button_Authent_myd.Enabled   = false;
                this.button_AuthentMifare.Enabled = false;

                this.checkBoxEnable.Checked = true;

                //Registry from Events send and receive
                fedm.AddEventListener(this, FeIscListenerConst.SEND_STRING_EVENT);
                fedm.AddEventListener(this, FeIscListenerConst.RECEIVE_STRING_EVENT);

                //Init from  TextEditor
                HexEdit.SetSize(128, 4, BnkIdx);

                //Thread starten in Background
                running = false;
                MyThread.IsBackground = true;
                MyThread.Start();
            }
            else
            {
                config.ShowDialog();
            }
        }