コード例 #1
0
        /// <summary>
        /// Queries data from the vehicle by sending a specific mode and PID
        /// </summary>
        /// <param name="parameterMode"> <c>Vehicle.Mode</c> used </param>
        /// <param name="parameterID"> <c>Vehicle.PID</c> indicating the information to query </param>
        /// <returns> <c>ControllerResponse</c> object holding the returned data from the controller unit </returns>
        /// <remarks> Blocking until a complete answer has been received </remarks>
        public ControllerResponse Query(Vehicle.Mode parameterMode, Vehicle.PID parameterID)
        {
            Port.Write(Convert.ToUInt32(parameterMode).ToString("X2") + Convert.ToUInt32(parameterID).ToString("X2") + "\r");
            Thread.Sleep(100);

            string fullResponse = "";
            while(!fullResponse.Contains(">"))
            {
                byte[] readBuffer = new byte[1024];
                Port.Read(readBuffer, 0, 1024);
                fullResponse = System.Text.Encoding.Default.GetString(readBuffer);
            }

            return new ControllerResponse(fullResponse, parameterMode, parameterID);
        }
コード例 #2
0
 public ControllerResponse(string raw, Vehicle.Mode requestedMode = Vehicle.Mode.Unknown, Vehicle.PID requestedPID = Vehicle.PID.Unknown)
 {
     Raw = raw;
     RequestedPID = requestedPID;
     RequestedMode = requestedMode;
 }