Example #1
0
 //Usata quando viene premuto il tasto send
 private void btnCommand_Click(object sender, EventArgs e)
 {
     byte[] command = { (byte)System.Enum.Parse(typeof(Param.Commands), cboCommand.SelectedValue.ToString(), false), 0x00 };
     try
     {
         if (((Param.Commands)command[0]) == Param.Commands.START)
         {
             isStarted = true;
             syncPolling.sveglia();
         }
         else
         {
             isStarted = false;
         }
         ComPort.Write(command, 0, 2);
     }
     catch (System.InvalidOperationException)
     {
         MessageBox.Show("Hai dimenticato di Aprire la Connessione", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (System.IO.IOException)
     {
         MessageBox.Show("Errore comunicazione", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }