Ejemplo n.º 1
0
        private void ProcessData()
        {
            byte msgType = payloadBuff[3];

            switch (msgType)
            {
            case 0:
                StatusMessageReceived?.Invoke(StatusMessage.InitFailed);
                break;

            case 1:
                StatusMessageReceived?.Invoke(StatusMessage.InitOk);
                break;

            case 2:
                StatusMessageReceived?.Invoke(StatusMessage.CrcError);
                break;

            case 3:
                byte[] buffer = new byte[payloadLen];

                Buffer.BlockCopy(payloadBuff, 4, buffer, 0, payloadLen);
                try
                {
                    TxRxPayload trp = new TxRxPayload(buffer);
                    PayloadReceived?.Invoke(trp);
                }
                catch (Exception e)
                {
                    UnrecognizedPayloadReceived?.Invoke(buffer);
                }
                break;

            case 4:
                StatusMessageReceived?.Invoke(StatusMessage.GetFifoError);
                break;

            case 5:
                StatusMessageReceived?.Invoke(StatusMessage.GetIntError);
                break;
            }
        }
Ejemplo n.º 2
0
 private void SerialMan_PayloadReceived(TxRxPayload payload)
 {
     Console.WriteLine(payload);
 }