示例#1
0
        public static byte[] DoIO(IntPtr sctp, int command, byte[] data, int[] excpectedReturnCodes)
        {
            int ReturnCode = 0;

            byte[] ResponseBuffer = new byte[512];
            int    ResponseLength = ResponseBuffer.Length;

            LowLevelError Error = ScpCommands.sccp_io(sctp, command, data, data.Length, ref ReturnCode, ResponseBuffer, ref ResponseLength);

            ScpCommands.CheckError(Error);

            bool ExpectedReturnCodeFound = false;

            foreach (int ExceptedReturnCode in excpectedReturnCodes)
            {
                if (ReturnCode == ExceptedReturnCode)
                {
                    ExpectedReturnCodeFound = true;
                    break;
                }
            }
            if (ExpectedReturnCodeFound == false)
            {
                throw new ScpException((LowLevelError)ReturnCode);
            }

            if (ResponseLength > 0)
            {
                byte[] ResponseData = new byte[ResponseLength];
                Array.Copy(ResponseBuffer, 0, ResponseData, 0, ResponseLength);

                return(ResponseData);
            }
            else
            {
                return(null);
            }
        }