bluesky8059

Untitled

Apr 12th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 KB | None | 0 0
  1.                 copyBuffer = new byte[375];
  2.                             Byte receivedValue = (Byte)port.ReadByte();
  3.                             //If receive 0xAA, start count how many 0xAA are
  4.                            
  5.                             if (receivedValue == 0xAA)
  6.                             {
  7.                                 cnt++;
  8.                                 if (cnt == 6)
  9.                                 {
  10.                                     port.Read(copyBuffer, 7, 368);
  11.                                     for (int i = 7; i < 375; i++)
  12.                                         Console.Write(copyBuffer[i] + ",");
  13.                                     Console.WriteLine();
  14.                                         copyBuffer[0] = 0x41;
  15.                                     for (int i = 1; i <= 6; i++)
  16.                                         copyBuffer[i] = 0xAA;
  17.                                    
  18.                                     totalprocessed++;
  19.                                     sw.Stop();
  20.                                     string result = sw.Elapsed.TotalSeconds.ToString();
  21.                                     Console.WriteLine("Total : " + totalprocessed + " Time : " + result);
  22.                                     copyBuffer = null;
  23.                                    
  24.                                 }
  25.                                
  26.                             }
  27.                             else
  28.                             {
  29.                                 cnt = 0;
  30.                             }
  31.                             /*
  32.                             if (isOK)
  33.                             {
  34.                                 DisplayArr(copyBuffer);
  35.                                 isOK = false;
  36.                             }
  37.                             else
  38.                             {
  39.                                 Console.WriteLine("Something Wrong");
  40.                             }*/
  41.  
  42.  
  43.                             hand_cnt++;
  44.                             if (hand_cnt == 100)
  45.                                 hand_cnt = 0;
Advertisement
Add Comment
Please, Sign In to add comment