private void Read_serial(object sender, EventArgs e) { try { Serial_read = serialPort1.ReadLine(); txt_msgBox.Text = Serial_read; txt_msgArduino.Visible = true; txt_msgArduino.Text = Serial_read; if ((Serial_read.IndexOf("@") > 0)) { msg_portCom = Serial_read.Substring(0, (Serial_read.IndexOf("@"))); id_biometria = msg_portCom; Biometry_Authentication(); } if (Serial_read.IndexOf("#") > 0) { msg_portCom = Serial_read.Substring(0, (Serial_read.IndexOf("#"))); rtn_Arduino_Ebox = int.Parse(msg_portCom); if (rtn_Arduino_Ebox == 1) { btn_Porta.Text = "COMPARTIMENTO ABERTO"; btn_Porta.BackColor = Color.Lime; btn_Porta.ForeColor = Color.Red; btn_ConfirmarPage3.Enabled = true; Registra_Retirada(); } else if (rtn_Arduino_Ebox == 2) { btn_Porta.Text = "COMPARTIMENTO FECHADO"; btn_Porta.BackColor = Color.MidnightBlue; btn_Porta.ForeColor = Color.Gold; } else if (rtn_Arduino_Ebox == 3) { btn_Porta.Text = "COMPARTIMENTO ERROR"; btn_Porta.BackColor = Color.Red; btn_Porta.ForeColor = Color.Gold; btn_cancelaRetirada.Enabled = true; } } } catch { MessageBox.Show("A CONEXÃO COM O ARDUINO FOI PERDIDA. ", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Read_serial(object sender, EventArgs e) { //Serial_read = serialPort1.ReadLine(); Serial_read = serialPort1.ReadExisting(); txt_msgBox.Text = Serial_read; if (Serial_read.IndexOf("#") > 0) { txt_idBiometria.Text = Serial_read.Substring(0, (Serial_read.IndexOf("#"))); picture_biometria.Image = CondoBiometry.Properties.Resources.digital; txt_msgBox.Visible = false; } }