/// <summary>
        /// Receive data from a blade serial session
        /// </summary>
        public SerialDataResponse ReceiveBladeSerialData(int bladeId, string sessionToken)
        {
            SerialDataResponse response = new SerialDataResponse();
            response.completionCode = Contracts.CompletionCode.Unknown;
            response.statusDescription = String.Empty;

            Tracer.WriteInfo("Received ReceiveBladeSerialData(bladeId: {0}) API", bladeId);
            Tracer.WriteUserLog("Invoked ReceiveBladeSerialData(bladeId: {0}, sessionToken: {1}) API", bladeId, sessionToken);

            if (ChassisManagerUtil.CheckBladeId((byte)bladeId) != (byte)CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                Tracer.WriteWarning("ReceiveBladeSerialData failed: Blade ID: {0} out of range: ", bladeId);
                return response;
            }

            Contracts.ChassisResponse chassisResponse = CheckBladeAndFirmwareState((byte)bladeId);
            if (chassisResponse.completionCode != Contracts.CompletionCode.Success)
            {
                response.completionCode = chassisResponse.completionCode;
                response.statusDescription = chassisResponse.statusDescription;
                return response;
            }

            if (!FunctionValidityChecker.CheckBladeTypeValidity((byte)bladeId))
            {
                response.completionCode = Contracts.CompletionCode.CommandNotValidForBlade;
                return response;
            }

            response = ChassisState.BladeSerialMetadata[bladeId].ReceiveBladeSerialData(bladeId, sessionToken);

            if (ChassisManagerUtil.CheckCompletionCode(response.completionCode))
            {
                Tracer.WriteInfo("ReceiveBladeSerialData succeeded for bladeId: " + bladeId);
            }
            else if (response.completionCode == Contracts.CompletionCode.Timeout)
            {
                Tracer.WriteInfo("ReceiveBladeSerialData: No data received from bladeId: {0} (expected timeout).", bladeId);
            }
            else if (response.completionCode == Contracts.CompletionCode.BmcRxSerialBufferOverflow)
            {
                Tracer.WriteInfo("ReceiveBladeSerialData: BMC Rx Serial Buffer Overflow on blade: {0}", bladeId);
            }
            else
            {
                Tracer.WriteError("ReceiveBladeSerialData failed for bladeId: {0} with completion code: {1}", bladeId, response.completionCode.ToString());
            }

            response.statusDescription = response.completionCode.ToString();
            return response;
        }
        /// <summary>
        /// Receive data from a port serial session
        /// </summary>
        public SerialDataResponse ReceiveSerialPortData(int portId, string sessionToken)
        {
            SerialDataResponse response = new SerialDataResponse();
            response.completionCode = Contracts.CompletionCode.Unknown;
            response.statusDescription = String.Empty;

            Tracer.WriteUserLog("Invoked ReceiveSerialPortData(portId: {0}, sessionToken: {1})", portId, sessionToken);
            Tracer.WriteInfo("Received ReceiveSerialPortData({0})", portId);

            if (ChassisManagerUtil.CheckSerialConsolePortId((byte)portId) != (byte)CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.ParameterOutOfRange;
                Tracer.WriteWarning("ReceiveSerialPortData failed: ParameterOutOfRange for Port ID " + portId);
                response.statusDescription = String.Format("ReceiveSerialPortData failed: ParameterOutOfRange for Port ID " + portId);
                return response;
            }

            int portIndex = ChassisManagerUtil.GetSerialConsolePortIndexFromId(portId);
            response = ChassisState.SerialConsolePortsMetadata[portIndex].ReceiveSerialPortData(ChassisManagerUtil.GetSerialConsolePortIdFromIndex(portIndex), sessionToken);

            // Set Http code status
            if (ChassisManagerUtil.CheckCompletionCode(response.completionCode))
            {
                Tracer.WriteInfo("ReceiveSerialPortData succeeded for portId: " + portId);
            }
            else if (response.completionCode == Contracts.CompletionCode.Timeout)
            {
                Tracer.WriteInfo("ReceiveSerialPortdata: No data to be received from portId: {0} (expected timeout).", portId);
                response.statusDescription = String.Format("ReceiveSerialPortdata: No data to be received from portId: {0} (expected timeout).", portId);
            }
            else
            {
                Tracer.WriteError("ReceiveSerialPortData: failed for portId: {0} with completion code: {1}", portId, response.completionCode.ToString());
                response.statusDescription = String.Format("ReceiveSerialPortData: failed for portId: {0} with completion code: {1}", portId, response.completionCode.ToString());
            }
            return response;
        }
 private TestResponse VerifyReceiveSerialPortDataByUser(TestResponse response, WCSSecurityRole roleId, SerialDataResponse receiveDataResponse)
 {
     if (!(CompletionCode.Success == receiveDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmAdmin || roleId == WCSSecurityRole.WcsCmOperator))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("\nFailed to receive serial port data with WcsAdmin/WcsOperator User {0}, completion code returned: {1} ", roleId, receiveDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else if ((CompletionCode.Success == receiveDataResponse.completionCode) && (roleId == WCSSecurityRole.WcsCmUser))
     {
         response.Result = false;
         response.ResultDescription.Append(string.Format("User is able to receive serial port data {0}", roleId, "completion code returned: {1} ", receiveDataResponse.completionCode));
         CmTestLog.Failure(response.ResultDescription.ToString());
         return response;
     }
     else
     {
         response.Result &= ChassisManagerTestHelper.IsTrue(CompletionCode.Success == receiveDataResponse.completionCode,
             string.Format("Received success with user {0}", Enum.GetName(typeof(WCSSecurityRole), roleId)));
     }
     return response;
 }