示例#1
0
        /// <summary>
        /// Sends and receives a BTU request/response to the target. Uses existing PTU functionality.
        /// The response is saved (the Mode isn't)
        /// </summary>
        /// <param name="mode">desired mode</param>
        /// <param name="requestBuffer">request buffer (must be populated with desired payload prior to being called)</param>
        /// <returns></returns>
        public static int PTU_MVB_Interface(ushort mode, ushort [] requestBuffer)
        {
            if (m_SerComm == null)
            {
                return(-2);
            }
            ushort[] payload = new ushort[17];

            for (int i = 0; i < payload.Length; i++)
            {
                payload[i] = requestBuffer[i];
            }

            // Create the BTU request object with the Mode and the Request
            ProtocolPTU.BtuReq request = new ProtocolPTU.BtuReq(mode, payload);

            PtuTargetCommunication ptuTargetComm = new PtuTargetCommunication();

            // Transmit the message... the response is stored in rxMessage
            byte [] rxMessage = new byte[1024];
            int     commError = ptuTargetComm.SendDataRequestToEmbedded(m_SerComm, request, rxMessage);

            // If no errors exist, store the target response starting at byte 10 (bytes 0-7 are the header
            // bytes 8 & 9 are the "Mode")
            if (commError == 0)
            {
                for (int i = 0; i < 17; i++)
                {
                    m_ResultBuffer[i] = BitConverter.ToUInt16(rxMessage, ((i * 2) + 10));
                    if (m_SerComm.IsTargetBigEndian())
                    {
                        m_ResultBuffer[i] = Utils.ReverseByteOrder(m_ResultBuffer[i]);
                    }
                }
            }

            return(commError);
        }
 /// <summary>
 /// Constructor that initializes a new instance of the CommGen class
 /// </summary>
 /// <param name="device">The communication vehicle used to access the PTU target (VCU)</param>
 public WatchClockMarshal(ICommDevice device)
 {
     m_CommDevice             = device;
     m_PtuTargetCommunication = new PtuTargetCommunication();
 }