public override EusbPdu ParsePdu(byte[] data) { EusbPdu pdu; switch (GetPduType(data)) { case EusbType.RIM_EXCHANGE_CAPABILITY_REQUEST: pdu = new EusbRimExchangeCapResponsePdu(); break; case EusbType.ADD_VIRTUAL_CHANNEL: pdu = new EusbAddVirtualChannelPdu(); break; case EusbType.ADD_DEVICE: pdu = new EusbAddDevicePdu(); break; case EusbType.CHANNEL_CREATED: pdu = new EusbChannelCreatedPdu(false); break; case EusbType.QUERY_DEVICE_TEXT: pdu = new EusbQueryDeviceTextResponsePdu(); break; case EusbType.IOCONTROL_COMPLETION: pdu = new EusbIoControlCompletionPdu(); break; case EusbType.URB_COMPLETION: pdu = new EusbUrbCompletionPdu(); break; case EusbType.URB_COMPLETION_NO_DATA: pdu = new EusbUrbCompletionNoDataPdu(); break; default: return base.ParsePdu(data); } if (!PduMarshaler.Unmarshal(data, pdu)) { pdu = new EusbUnknownPdu(); PduMarshaler.Unmarshal(data, pdu); } return pdu; }
/// <summary> /// This method is used to verify the URB_COMPLETION PDU. /// </summary> /// <param name="responsePdu">The PDU from the client.</param> /// <param name="tsUrb">The TS_URB in the request.</param> /// <param name="requestCompletion">A unique InterfaceID to be set in the Register Request Callback Message.</param> public static void VerifyUrbCompletion(EusbUrbCompletionPdu responsePdu, TS_URB tsUrb, uint requestCompletion) { Site.Assert.AreEqual<uint>( requestCompletion, responsePdu.InterfaceId, "Expect that the InterfaceId in the response PDU equals the RequestCompletion field of the REGISTER_REQUEST_CALLBACK PDU. The actual value is 0x{0:x8}.", responsePdu.InterfaceId); Site.Assert.AreEqual<Mask_Values>( Mask_Values.STREAM_ID_PROXY, responsePdu.Mask, "Expect that the Mask in the response PDU is STREAM_ID_PROXY."); Site.Assert.AreEqual<FunctionId_Values>( FunctionId_Values.URB_COMPLETION, (FunctionId_Values)responsePdu.FunctionId, "Expect that the FunctionId in the response PDU is CHANNEL_CREATED. The actual value is 0x{0:x8}.", responsePdu.FunctionId); Site.Assert.AreEqual<uint>( tsUrb.Header.RequestId, responsePdu.RequestId, "Expect that the RequestId in the response PDU equals the RequestId in the request PDU. The actual value is 0x{0:x8}.", responsePdu.RequestId); }