Exemple #1
0
        private void buttonSetGPIO_Click(object sender, EventArgs e)
        {
            byte OutputPin = 0;

            if (checkBoxOUT1.Checked)
            {
                OutputPin = Convert.ToByte(OutputPin | 0x01);
            }
            if (checkBoxOUT2.Checked)
            {
                OutputPin = Convert.ToByte(OutputPin | 0x02);
            }
            try
            {
                ErrorsCatcher.errorName = RWDev.SetGPIO(ref RWDev.comAddress, OutputPin, RWDev.frmComPortIndex);
                if (ErrorsCatcher.errorName != 0)
                {
                    string strLog = "Set GPIO failed " + ErrorsCatcher.GetReturnCodeDesc(ErrorsCatcher.errorName) + Environment.NewLine;
                    richTextBoxLogs.AppendText(strLog);
                    return;
                }
                else
                {
                    string strLog = "Set GPIO success" + Environment.NewLine;
                    richTextBoxLogs.AppendText(strLog);
                }
            }
            catch
            {
                richTextBoxLogs.AppendText("Set GPIO failed!" + Environment.NewLine);
            }
        }