Пример #1
0
        public static void Read()
        {
            GlobalVars.VISA_CLI_ReadBackBuffer = null;
            // GlobalVars.VISA_CLI_ReadBackBuffer = GlobalVars.mbSession.ReadString(Convert.ToInt32(GlobalVars.VISA_CLI_Option_ReadBackNbytes));
            GlobalVars.VISA_CLI_ReadBackBuffer = GlobalVars.mbSession.ReadByteArray(Convert.ToInt32(GlobalVars.VISA_CLI_Option_ReadBackNbytes));
            //https://stackoverflow.com/questions/2530951/remove-first-16-bytes/2530994#2530994
            //https://stackoverflow.com/questions/5062233/is-there-a-away-to-convert-ilistarraysegmentbyte-to-byte-without-enumerati
            if (GlobalVars.VISA_CLI_Option_SkipFirstNbytes > 0)
            {
                ArraySegment <byte> segment = new ArraySegment <byte>(GlobalVars.VISA_CLI_ReadBackBuffer, Convert.ToInt32(GlobalVars.VISA_CLI_Option_SkipFirstNbytes), GlobalVars.VISA_CLI_ReadBackBuffer.Length - Convert.ToInt32(GlobalVars.VISA_CLI_Option_SkipFirstNbytes));
#if NET40
                if (GlobalVars.VISA_CLI_Option_PrintDebugMessage)
                {
                    Console.WriteLine(" .NET Framwork Version 4.0 : segment.AsList().ToArray()) ");
                }
                GlobalVars.VISA_CLI_ReadBackBuffer = segment.AsList().ToArray();
#else
                if (GlobalVars.VISA_CLI_Option_PrintDebugMessage)
                {
                    Console.WriteLine(" .NET Framwork Version > 4.0 : segment.ToArray()) "); // For   Newer than  .NET4.0 Framework Use  segment.ToArray()  https://docs.microsoft.com/en-us/dotnet/api/system.arraysegment-1.array?view=netframework-4.0
                }
                GlobalVars.VISA_CLI_ReadBackBuffer = segment.ToArray();
#endif
            }
        }