Ejemplo n.º 1
0
        private static void ECWrite(byte register, byte value, bool verbose)
        {
            AccessEcSynchronized(ec =>
            {
                if (verbose)
                {
                    Console.WriteLine("Writing at {0}: {1} (0x{1:X2})", register, value);
                }

                ec.WriteByte(register, value);

                if (verbose)
                {
                    byte b = ec.ReadByte(register);
                    Console.WriteLine("Current value at {0}: {1} (0x{1:X2})", register, b);
                }
            });
        }
Ejemplo n.º 2
0
        private static void ECMonitor(int timespan, int interval, string reportPath, bool clearly, bool decimalFormat)
        {
            var logs = new RegisterLog[byte.MaxValue];

            Console.CancelKeyPress += (sender, e) =>
            {
                if (reportPath != null)
                {
                    SaveRegisterLogs(reportPath, logs, clearly, decimalFormat);
                }
            };

            using (ec = LoadEC())
            {
                if (ec == null)
                {
                    return;
                }

                Console.WriteLine("monitoring...");

                for (byte b = 0; b < logs.Length; b++)
                {
                    AccessEcSynchronized(ec =>
                    {
                        logs[b].Values = new List <byte>();
                        logs[b].Values.Add(ec.ReadByte(b));
                    },
                                         ec);
                }

                int loopCount = 0;

                while ((timespan < 1) || (loopCount < Math.Ceiling(((double)timespan / interval) - 1)))
                {
                    Thread.Sleep(interval * 1000);
                    AccessEcSynchronized(ec =>
                    {
                        for (int i = 0; i < logs.Length; i++)
                        {
                            byte value = ec.ReadByte((byte)i);
                            logs[i].Values.Add(value);

                            if (value != logs[i].Values[0])
                            {
                                logs[i].Print = true;
                            }
                        }
                    },
                                         ec);

                    Console.Clear();
                    PrintRegisterLogs(logs, clearly, decimalFormat);
                    loopCount++;
                }
            }

            if (reportPath != null)
            {
                SaveRegisterLogs(reportPath, logs, clearly, decimalFormat);
            }
        }