예제 #1
0
 private void framer_packedArrivedEvent(object sender, SerialPacket e)
 {
     byte[] packet = e.GetPacket();
     if(packet.Length > 2)
     {
         //int val = (int)packet[packet.Length - 1];
         SetText(BitConverter.ToString(packet), label1);
         //MessageBox.Show(BitConverter.ToString(packet), "Odebrany pakiet danych");
         decode(packet);
     }
 }
예제 #2
0
 private void SyncProtocol(byte sync)
 {
     if (escaped)
     {
         serialBufferPtr = 0;
         escaped = false;
         return;
     }
     if (serialBufferPtr == 0)
     {
         CopyByteToBuffer(sync);
         return;
     }
     else if (CopyByteToBuffer(sync) >= MIN_FRAME_SIZE)
     {
         SerialPacket pck = new SerialPacket(serialBuffer, serialBufferPtr);
         if (pck.OkCrc())
             RaiseEventFrameArrived(pck);
     }
     serialBufferPtr = 0;
 }
예제 #3
0
 protected virtual void RaiseEventFrameArrived(SerialPacket frm)
 {
     EventHandler<SerialPacket> handler = packedArrivedEvent;
     if (handler != null)
     {
         handler(this, frm);
     }
 }