public static unsafe bool GetStrobe(this SmartScopeHeader hdr, STR s)
        {
            int  offset = Constants.HDR_STROBES[s];
            byte reg    = hdr.strobes[offset / 8];

            return(Utils.IsBitSet(reg, offset % 8));
        }
Beispiel #2
0
        public static int GetAcquisition(this ISmartScopeHardwareUsb usb, byte[] buffer)
        {
            usb.GetData(buffer, 0, Constants.SZ_HDR);
            GCHandle         handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            SmartScopeHeader hdr    = (SmartScopeHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SmartScopeHeader));

            handle.Free();
            if (!hdr.IsValid())
            {
                Logger.Error("Invalid header magic");
                return(0);
            }


            if (hdr.flags.HasFlag(HeaderFlags.TimedOut))
            {
                return(Constants.SZ_HDR);
            }

            if (hdr.flags.HasFlag(HeaderFlags.IsOverview))
            {
                usb.GetData(buffer, Constants.SZ_HDR, Constants.SZ_OVERVIEW);
                return(Constants.SZ_HDR + Constants.SZ_OVERVIEW);
            }

            if (hdr.n_bursts == 0)
            {
                throw new ScopeIOException("number of bursts in this USB pacakge is 0, cannot fetch");
            }

            int len = hdr.n_bursts * hdr.bytes_per_burst;

            usb.GetData(buffer, Constants.SZ_HDR, len);
            return(Constants.SZ_HDR + len);
        }
        public int GetAcquisition(byte[] buffer)
        {
            try
            {
                if (dataSocket == null)
                {
                    byte[] portBytes = Request(Net.Net.Command.DATA_PORT);
                    this.dataPort = BitConverter.ToUInt16(portBytes, 0);
                    dataClient.Connect(this.serverIp, this.dataPort);
                    dataClient.ReceiveBufferSize = Net.Net.DATA_SOCKET_BUFFER_SIZE;
                    dataSocket = dataClient.Client;
                    dataSocket.ReceiveTimeout = Net.Net.TIMEOUT_RX;
                }
                SocketReceive(dataSocket, 0, Constants.SZ_HDR, buffer);
                GCHandle         handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                SmartScopeHeader hdr    = (SmartScopeHeader)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(SmartScopeHeader));
                handle.Free();
                if (!hdr.IsValid())
                {
                    Logger.Error("Invalid header magic");
                    return(0);
                }


                if (hdr.flags.HasFlag(HeaderFlags.TimedOut))
                {
                    return(Constants.SZ_HDR);
                }

                if (hdr.flags.HasFlag(HeaderFlags.IsOverview))
                {
                    SocketReceive(dataSocket, Constants.SZ_HDR, Constants.SZ_OVERVIEW, buffer);
                    return(Constants.SZ_HDR + Constants.SZ_OVERVIEW);
                }

                if (hdr.n_bursts == 0)
                {
                    throw new ScopeIOException("number of bursts in this USB pacakge is 0, cannot fetch");
                }

                int len = hdr.n_bursts * hdr.bytes_per_burst;
                SocketReceive(dataSocket, Constants.SZ_HDR, len, buffer);
                return(Constants.SZ_HDR + len);
            }
            catch (SocketException se)
            {
                throw new ScopeIOException("Socket exception: " + se.Message);
            }
        }
 public static unsafe byte GetRegister(this SmartScopeHeader hdr, REG r)
 {
     return(hdr.regs[Constants.HDR_REGS[r]]);
 }
 public static unsafe bool IsValid(this SmartScopeHeader hdr)
 {
     return(hdr.magic[0] == 'L' && hdr.magic[1] == 'N');
 }