コード例 #1
0
        internal static Contracts.ChassisResponse SendBladeSerialData(int bladeId, string sessionToken, byte[] data)
        {
            Contracts.ChassisResponse response = new Contracts.ChassisResponse();
            response.completionCode = Contracts.CompletionCode.Failure;
            Tracer.WriteInfo("BladeSerialSessionMetadata.SendBladeSerialData({0})", bladeId);

            // If there is NOT an already existing Blade serial session (indicated by a invalid bladeId and a invalid sessionToken), return failure with appropriate completion code
            if (CompareAndSwapMetadata(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken) == CompletionCode.Success)
            {
                Tracer.WriteError("SendBladeSerialData({0}): Send failed because of no active session.", bladeId);
                response.completionCode = Contracts.CompletionCode.NoActiveSerialSession;
                return(response);
            }

            // If this bladeid currently holds the serial session, update the timestamp else return failure
            if (BladeSerialSessionMetadata.CompareAndSwapMetadata(bladeId, sessionToken, bladeId, sessionToken, DateTime.Now) != CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.SerialSessionActive;
                return(response);
            }

            BladeSerialSession currSession  = new BladeSerialSession((byte)bladeId);
            SerialStatusPacket serialStatus = new SerialStatusPacket();

            serialStatus = currSession.sendSerialData(data);
            if (serialStatus.completionCode != CompletionCode.Success)
            {
                Tracer.WriteError("BladeSerialSessionMetadata.SendBladeSerialData({0}): Error in BladeSerialSession.sendSerialData()", bladeId);
                return(response);
            }
            response.completionCode = Contracts.CompletionCode.Success;
            return(response);
        }
コード例 #2
0
        internal static Contracts.SerialDataResponse ReceiveBladeSerialData(int bladeId, string sessionToken)
        {
            Contracts.SerialDataResponse response = new Contracts.SerialDataResponse();
            response.completionCode = Contracts.CompletionCode.Failure;
            Tracer.WriteInfo("BladeSerialSessionMetadata.ReceiveBladeSerialData({0})", bladeId);

            // If there is NOT an already existing Blade serial session (indicated by a invalid bladeId and a invalid sessionToken), return failure with appropriate completion code
            if (CompareAndSwapMetadata(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken) == CompletionCode.Success)
            {
                Tracer.WriteError("ReceiveBladeSerialData({0}): Receive failed because of no active session.", bladeId);
                response.completionCode = Contracts.CompletionCode.NoActiveSerialSession;
                return(response);
            }

            // If this bladeid do not currently hold the serial session, return failure
            if (BladeSerialSessionMetadata.CompareAndSwapMetadata(bladeId, sessionToken, bladeId, sessionToken) != CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.SerialSessionActive;
                return(response);
            }

            BladeSerialSession currSession = new BladeSerialSession((byte)bladeId);
            SerialDataPacket   serialData  = new SerialDataPacket();

            serialData = currSession.receiveSerialData();
            if (serialData.completionCode != CompletionCode.Success)
            {
                // Common-case: lots of timeouts if device do not have any data to send over serial
                if (serialData.completionCode == CompletionCode.Timeout)
                {
                    Tracer.WriteInfo("BladeSerialSessionMetadata.ReceiveBladeSerialData({0}) Timeout in BladeSerialSession.receiveSerialData()", bladeId);
                    response.completionCode = Contracts.CompletionCode.Timeout;
                    return(response);
                }
                Tracer.WriteError("BladeSerialSessionMetadata.ReceiveBladeSerialData({0}) Error in BladeSerialSession.receiveSerialData()", bladeId);
                return(response);
            }

            response.data           = serialData.data;
            response.completionCode = Contracts.CompletionCode.Success;
            return(response);
        }
コード例 #3
0
        internal static Contracts.SerialDataResponse ReceiveBladeSerialData(int bladeId, string sessionToken)
        {
            Contracts.SerialDataResponse response = new Contracts.SerialDataResponse();
            response.completionCode = Contracts.CompletionCode.Failure;
            Tracer.WriteInfo("BladeSerialSessionMetadata.ReceiveBladeSerialData({0})", bladeId);

            // If there is NOT an already existing Blade serial session (indicated by a invalid bladeId and a invalid sessionToken), return failure with appropriate completion code
            if (CompareAndSwapMetadata(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken) == CompletionCode.Success)
            {
                Tracer.WriteError("ReceiveBladeSerialData({0}): Receive failed because of no active session.", bladeId);
                response.completionCode = Contracts.CompletionCode.NoActiveSerialSession;
                return response;
            }

            // If this bladeid do not currently hold the serial session, return failure
            if (BladeSerialSessionMetadata.CompareAndSwapMetadata(bladeId, sessionToken, bladeId, sessionToken) != CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.SerialSessionActive;
                return response;
            }

            BladeSerialSession currSession = new BladeSerialSession((byte)bladeId);
            SerialDataPacket serialData = new SerialDataPacket();
            serialData = currSession.receiveSerialData();
            if (serialData.completionCode != CompletionCode.Success)
            {
                // Common-case: lots of timeouts if device do not have any data to send over serial
                if (serialData.completionCode == CompletionCode.Timeout)
                {
                    Tracer.WriteInfo("BladeSerialSessionMetadata.ReceiveBladeSerialData({0}) Timeout in BladeSerialSession.receiveSerialData()", bladeId);
                    response.completionCode = Contracts.CompletionCode.Timeout;
                    return response;
                }
                Tracer.WriteError("BladeSerialSessionMetadata.ReceiveBladeSerialData({0}) Error in BladeSerialSession.receiveSerialData()", bladeId);
                return response;
            }

            response.data = serialData.data;
            response.completionCode = Contracts.CompletionCode.Success;
            return response;
        }
コード例 #4
0
        internal static Contracts.ChassisResponse SendBladeSerialData(int bladeId, string sessionToken, byte[] data)
        {
            Contracts.ChassisResponse response = new Contracts.ChassisResponse();
            response.completionCode = Contracts.CompletionCode.Failure;
            Tracer.WriteInfo("BladeSerialSessionMetadata.SendBladeSerialData({0})", bladeId);

            // If there is NOT an already existing Blade serial session (indicated by a invalid bladeId and a invalid sessionToken), return failure with appropriate completion code
            if (CompareAndSwapMetadata(ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken, ConfigLoaded.InactiveBladePortId, ConfigLoaded.InactiveBladeSerialSessionToken) == CompletionCode.Success)
            {
                Tracer.WriteError("SendBladeSerialData({0}): Send failed because of no active session.", bladeId);
                response.completionCode = Contracts.CompletionCode.NoActiveSerialSession;
                return response;
            }

            // If this bladeid currently holds the serial session, update the timestamp else return failure
            if (BladeSerialSessionMetadata.CompareAndSwapMetadata(bladeId, sessionToken, bladeId, sessionToken, DateTime.Now) != CompletionCode.Success)
            {
                response.completionCode = Contracts.CompletionCode.SerialSessionActive;
                return response;
            }

            BladeSerialSession currSession = new BladeSerialSession((byte)bladeId);
            SerialStatusPacket serialStatus = new SerialStatusPacket();
            serialStatus = currSession.sendSerialData(data);
            if (serialStatus.completionCode != CompletionCode.Success)
            {
                Tracer.WriteError("BladeSerialSessionMetadata.SendBladeSerialData({0}): Error in BladeSerialSession.sendSerialData()", bladeId);
                return response;
            }
            response.completionCode = Contracts.CompletionCode.Success;
            return response;
        }