Example #1
0
        public IList <bool[]> Execute(SumpConfiguration config)
        {
            Sump.Reset();
            var flags = new SumpFlags
            {
                Filter        = config.Filter,
                Demux         = config.Demux,
                ExternalClock = config.ExternalClock,
                InvertedClock = config.InvertedClock
            };

            for (int i = 0; i < 4; i++)
            {
                if (config.DisabledChannelGroups.ContainsKey(i) && config.DisabledChannelGroups[i] == true)
                {
                    flags.DisabledChannelGroups[i] = true;
                }
            }
            Sump.SetFlags(flags);
            if (config.TriggerSetup.Length > 4)
            {
                throw new NotSupportedException("It is not possible to have more than 4 trigger stages");
            }
            for (int i = 0; i < config.TriggerSetup.Length; i++)
            {
                if (config.TriggerSetup[i] == null)
                {
                    continue;
                }
                //setup stages
                var stage = new TriggerConfiguration();
                stage.Channel = config.TriggerSetup[i].Channel ?? 0;
                stage.Delay   = config.TriggerSetup[i].Delay;
                stage.Level   = config.TriggerSetup[i].Level;
                stage.Serial  = config.TriggerSetup[i].Channel.HasValue;
                stage.Start   = config.TriggerSetup[i].Start;
                Sump.SetTriggerConfigurations(i, stage);

                bool[] mask   = new bool[32];
                bool[] values = new bool[32];
                for (int j = 0; j < 32; j++)
                {
                    var item = config.TriggerSetup[i].Values;
                    //setup masks
                    if (item.ContainsKey(j))
                    {
                        mask[j]   = true;
                        values[j] = item[j] > 0 ? true : false;
                    }
                }
                Sump.SetTriggerMasks(i, mask);
                Sump.SetTriggerValues(i, values);
            }
            //setup sample count
            Sump.SetReadAndDelayCount(config.ReadCount / 4, config.DelayCount / 4);
            Sump.SetDivider(Sump.Clock / config.SampleFrequency);
            Sump.Run();
            return(Sump.GetData(config.ReadCount / 4, 100000, 500));
        }
Example #2
0
        public IList<bool[]> Execute(SumpConfiguration config)
        {
            Sump.Reset();
            var flags=new SumpFlags
              	{
                Filter=config.Filter,
                Demux=config.Demux,
                ExternalClock=config.ExternalClock,
                InvertedClock=config.InvertedClock
            };
            for(int i=0;i<4;i++)
            {
                if(config.DisabledChannelGroups.ContainsKey(i) && config.DisabledChannelGroups[i]==true)
                {
                    flags.DisabledChannelGroups[i]=true;
                }
            }
            Sump.SetFlags(flags);
            if(config.TriggerSetup.Length>4)
            {
                throw new NotSupportedException("It is not possible to have more than 4 trigger stages");
            }
            for(int i=0;i<config.TriggerSetup.Length;i++)
            {
                if(config.TriggerSetup[i]==null)
                {
                    continue;
                }
                //setup stages
                var stage=new TriggerConfiguration();
                stage.Channel=config.TriggerSetup[i].Channel ?? 0;
                stage.Delay=config.TriggerSetup[i].Delay;
                stage.Level=config.TriggerSetup[i].Level;
                stage.Serial=config.TriggerSetup[i].Channel.HasValue;
                stage.Start=config.TriggerSetup[i].Start;
                Sump.SetTriggerConfigurations(i, stage);

                bool[] mask=new bool[32];
                bool[] values=new bool[32];
                for(int j=0;j<32;j++)
                {
                    var item=config.TriggerSetup[i].Values;
                    //setup masks
                    if(item.ContainsKey(j))
                    {
                        mask[j]=true;
                        values[j]=item[j] > 0 ? true : false;
                    }
                }
                Sump.SetTriggerMasks(i, mask);
                Sump.SetTriggerValues(i, values);
            }
            //setup sample count
            Sump.SetReadAndDelayCount(config.ReadCount/4, config.DelayCount/4);
            Sump.SetDivider(Sump.Clock / config.SampleFrequency);
            Sump.Run();
            return Sump.GetData(config.ReadCount/4, 100000, 500);
        }
Example #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("MonoSump -- Sump Logic Analyzer Client");

            var handler=new ArgumentHandler();
            var commands=handler.ParseCommands(args);
            if(commands==null)
            {
                return;
            }
            var config=new SumpConfiguration();
            if(commands.ConfigFile!=null)
            {
                var json=LoadFile(commands.ConfigFile);
                config=SumpConfiguration.LoadFromJson(json);
            }
            else
            {
                //apply command options
                config.DelayCount=config.ReadCount=commands.Samples;
                config.SampleFrequency=commands.Frequency;
                config.TriggerSetup[0]=new TriggerStageConfiguration();
                foreach(var kv in commands.Triggers)
                {
                    config.TriggerSetup[0].Values.Add(kv);
                }
                config.TriggerSetup[0].Start=true;
            }

            using(var serial=new Serial(commands.DeviceName, 115200))
            {
                var sump=new SumpController(new SumpCommander(serial), commands.Verbose);
                if(commands.Identify)
                {
                    sump.Sump.Reset();
                    Console.WriteLine(sump.Sump.GetID());
                }
                var data=sump.Execute(config);

                Console.WriteLine("# done with "+data.Count+" frames");
                var sb=new StringBuilder();
                foreach(var d in data)
                {
                    foreach(var b in d)
                    {
                        if(b)
                        {
                            sb.Append("1");
                        }else
                        {
                            sb.Append("0");
                        }
                    }
                    sb.AppendLine("");
                }
                if(commands.DataOut!=null)
                {
                    if(commands.JsonOut)
                    {
                        WriteFile(commands.DataOut, data.ToJson());
              		}
                    else
                    {
                        WriteFile(commands.DataOut, sb.ToString());
                    }
                }
                Console.WriteLine(sb.ToString());
            }
        }