private void OpenSerialPort()
 {
     try
     {
         fedm.ConnectCOMM((int)this.comboBoxPortnumber.SelectedItem, true);
         fedm.SetPortPara("Baud", (this.comboBoxBaudrate.SelectedItem).ToString());
         fedm.SetPortPara("frame", (this.comboBoxFrame.SelectedItem).ToString());
         fedm.SetPortPara("timeout", this.textBoxTimeoutSP.Text);
     }
     catch (FePortDriverException ex)
     {
         MessageBox.Show(ex.ToString(), "Connection Error!");
     }
 }
Example #2
0
        private void buttonConnect_CheckedChanged(object sender, System.EventArgs e)
        {
            if (buttonConnect.Checked)
            {
                try
                {
                    this.UseWaitCursor = true;
                    buttonConnect.Text = "Dis&connect";
                    reader.ConnectCOMM(Int32.Parse((string)comboSerialPort.SelectedItem), true);

                    // Set the parameters
                    reader.SetBusAddress((byte)Int32.Parse(textBoxBusAddress.Text));
                    reader.SetPortPara("Timeout", textBoxTimeout.Text);

                    reader.ReadReaderInfo();                // read important reader info
                    reader.ReadCompleteConfiguration(true); // read reader's configuration from EEPROM (this need some time!)

                    // add the listener
                    reader.AddEventListener(this, FeIscListenerConst.SCANNER_PRT_EVENT);
                    this.UseWaitCursor = false;
                }
                catch (Exception)
                {
                    if (reader.Connected)
                    {
                        try
                        {
                            reader.RemoveEventListener(this, FeIscListenerConst.SCANNER_PRT_EVENT);
                            reader.DisConnect();
                        }
                        catch (Exception) {}
                    }
                    buttonConnect.Checked = false;
                    buttonConnect.Text    = "&Connect";
                    return;
                }
            }
            else
            {
                try
                {
                    buttonConnect.Text = "&Connect";
                    // remove the listener
                    reader.RemoveEventListener(this, FeIscListenerConst.SCANNER_PRT_EVENT);
                    reader.DisConnect();
                }
                catch (Exception) {}
            }
        }
        private void Form1_Load(object sender, System.EventArgs e)
        {
//			int back = 0;
            try
            {
                reader = new FedmIscReader();
                mux    = new FedmIscFunctionUnit(reader, FedmIscFunctionUnit.FU_TYPE_MUX);
                umux   = new FedmIscFunctionUnit(reader, FedmIscFunctionUnit.FU_TYPE_UMUX);
                dat    = new FedmIscFunctionUnit(reader, FedmIscFunctionUnit.FU_TYPE_DAT);

// the next block is a supplement to manage a complex function unit tree with one root element
// but be care with this methods !! Please have a look to the ISC.SDK.NET manual.
// enable this block for debugging purpose

/*				back = mux.AddChild(1, dat);// a previous created function unit object is added to the
 *											// child list of the root
 *
 *                              FedmIscFunctionUnit child;	// local declaration of a child
 *                              child = mux.GetChild(1);	// local child object is returned from internal child list
 *                                                                                      // (identical with object dat)
 *
 *                              back = mux.DeleteChild(1);	// child is removed from internal table, but the object (dat)
 *                                                                                      // exists continuously.
 *                              child = mux.GetChild(1);	// child is unvalid
 *                              back = mux.DeleteChild(1);	// nothing happens
 */
            }
            catch (FedmException ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                reader.ConnectCOMM(1, true);                // COM-Port 1
                reader.SetBusAddress(255);
                reader.SetPortPara("Baud", "38400");
                reader.SetPortPara("Frame", "8E1");
            }
            catch (FedmException ex)
            {
                MessageBox.Show(ex.Message, "Error - FedmException");
            }
            catch (FePortDriverException ex)
            {
                MessageBox.Show(ex.Message, "Error - FePortDriverException");
            }
        }
 private void OpenSerialPort()
 {
     try
     {
         fedm.ConnectCOMM((int)this.comboBoxPortnumber.SelectedItem, true);  // Parameter "true" --> with Detect, reads also the ReadInfo
         fedm.SetPortPara("Baud", (this.comboBoxBaudrate.SelectedItem).ToString());
         fedm.SetPortPara("frame", (this.comboBoxFrame.SelectedItem).ToString());
         fedm.SetPortPara("timeout", this.textBoxTimeoutSP.Text);
     }
     catch (FedmException ex)
     {
         MessageBox.Show(ex.ToString(), "Error");
     }
     catch (FePortDriverException ex)
     {
         MessageBox.Show(ex.ToString(), "Error");
     }
 }