Esempio n. 1
0
 private void scanning(object sender, DoWorkEventArgs e)
 {
     for (int opakuj = 0; opakuj < 10; opakuj++)
     {
         for (int poc_com = 0; poc_com < 20; poc_com++)
         {
             if (Isobot_com.IsOpen == true)
             {
                 Isobot_com.Close();
             }
             Isobot_com.PortName = "COM" + poc_com.ToString();
             try
             {
                 Isobot_com.Open();
                 System.Threading.Thread.Sleep(200);
                 Isobot_com.Write("A");
                 Isobot_com.ReadTimeout = 500;
                 if (Isobot_com.ReadByte() == 5)
                 {
                     MessageBox.Show("Connection established");
                     poc_com = 21;
                     opakuj  = 11;
                 }
             }
             catch { }
         }
     }
     if (Isobot_com.IsOpen == false)
     {
         MessageBox.Show("Connection has not been established");
     }
 }
Esempio n. 2
0
 void Send_onlycommand(string command)
 {
     try
     {
         byte[] pomocny = new byte[1];
         pomocny[0] = Convert.ToByte(command);
         Isobot_com.Write(pomocny, 0, 1);
     }
     catch
     {
         MessageBox.Show("Connection has not been established");
     }
 }
Esempio n. 3
0
 void Send_command(string command, string[] parameter)
 {
     try
     {
         byte[] pomocny = new byte[1];
         pomocny[0] = Convert.ToByte(command);
         Isobot_com.WriteTimeout = 100;
         Isobot_com.Write(pomocny, 0, 1);
         System.Threading.Thread.Sleep(2);
         //-----------------------------------------------
         for (int p = 0; p < parameter.Length; p++)
         {
             pomocny[0] = Convert.ToByte(parameter[p]);
             Isobot_com.Write(pomocny, 0, 1);
             System.Threading.Thread.Sleep(2);
         }
     }
     catch
     {
         MessageBox.Show("Connection has not been established");
     }
 }