コード例 #1
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
            public IEnumerable <Sample> GetData()
            {
                if (check)
                {
                    check = false;

                    if (smbus.Available)
                    {
                        int MFR_MODEL = smbus.GetReg(ADDRESS, 0x9a, 2);
                        available = MFR_MODEL == 0x3298;
                    }
                    else
                    {
                        available = false;
                    }
                }

                if (available)
                {
                    int VOUT = smbus.GetReg(ADDRESS, 0x8b, 2);
                    int IOUT = smbus.GetReg(ADDRESS, 0x8c, 2);
                    int POUT = smbus.GetReg(ADDRESS, 0x96, 2);

                    var VID     = GetVID(VOUT);
                    var Power   = ReadLiteral(POUT);
                    var Current = ReadLiteral(IOUT);

                    yield return(Sample.Voltage("CPU VID", VID, true));

                    yield return(Sample.Other("CPU Current", Current, true));

                    yield return(Sample.Other("CPU Power", Power, true));
                }
            }
コード例 #2
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
        public IEnumerable <Sample> GetData()
        {
            if (device == DeviceType.Unknown || device == DeviceType.NotPresent)
            {
                yield break;
            }

            double
                cpufanout0rpm   = 0,
                sysfanoutrpm    = 0,
                auxfanout0rpm   = 0,
                cpufanout1rpm   = 0,
                motherboardtemp = 0,
                cputin          = 0xFF,
                systin          = 0xFF,
                auxtin          = 0xFF;

            var cs = Read(BankSelect);

            while (cputin >= 99 || cputin <= -55)
            {
                Select(1);
                cputin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (auxtin >= 99 || auxtin <= -55)
            {
                Select(2);
                auxtin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (systin >= 99 || systin <= -55)
            {
                Select(0);
                systin = (sbyte)Read(0x27);
            }

            if (manufacturer == "ASUSTeK Computer INC." && product.StartsWith("P7P55D"))
            {
                // only on ASUS P7P55D
                var sio = new SuperIO {
                    BaseAddress = sioport
                };

                sio.Enter();
                var css = sio.Read(sio.BankSelect);
                sio.Select(0xc);
                var cr20 = sio.Read(0x20);
                sio.Select(css);
                sio.Exit();

                if (cr20 == 0xb3)
                {
                    Select(0);
                    Write(0x7d, 0); // seems to be some other values in 1,2,3,4
                    motherboardtemp = Read(0x7e);
                }
                else
                {
                    motherboardtemp = systin;
                }
            }

            var cputinavg = double.IsNaN(lastcputin) ? cputin : (cputin + lastcputin) / 2;

            lastcputin = cputin;

            var cpufanspeed0 = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["CPUFAN0"]);
            var sysfanspeed  = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["SYSFAN"]);

            Select(0);
            Write(0x4, 0);
            Write(1, sysfanspeed);
            Write(3, cpufanspeed0);

            var cpufanout0 = Read(0x29);

            int failcount = 0;

            while ((cpufanout0 == 0xff || cpufanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout0 = Read(0x29);
                failcount++;
            }

            if (failcount < 5 && cpufanout0 > 0 && cpufanout0 < 255)
            {
                var cpufanout0div = ((Read(0x47) >> 6) & 3) | (((Read(0x5d) >> 6) & 1) << 2);
                cpufanout0rpm = GetRPM(cpufanout0, cpufanout0div);
            }

            failcount = 0;

            var sysfanout = Read(0x28);

            while ((sysfanout == 0xff || sysfanout == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                sysfanout = Read(0x28);
                failcount++;
            }

            if (failcount < 5 && sysfanout > 0 && sysfanout < 255)
            {
                var sysfanoutdiv = ((Read(0x47) >> 4) & 3) | (((Read(0x5d) >> 5) & 1) << 2);
                sysfanoutrpm = GetRPM(sysfanout, sysfanoutdiv);
            }

            failcount = 0;

            var auxfanout0 = Read(0x2a);

            while ((auxfanout0 == 0xff || auxfanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                auxfanout0 = Read(0x2a);
                failcount++;
            }

            if (failcount < 5 && auxfanout0 > 0 && auxfanout0 < 255)
            {
                var auxfanout0div = ((Read(0x4b) >> 6) & 3) | (((Read(0x5d) >> 7) & 1) << 2);
                auxfanout0rpm = GetRPM(auxfanout0, auxfanout0div);
            }

            failcount = 0;

            var cpufanout1 = Read(0x3f);

            while ((cpufanout1 == 0xff || cpufanout1 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout1 = Read(0x3f);
                failcount++;
            }

            if (failcount < 5 && cpufanout1 > 0 && cpufanout1 < 255)
            {
                var cpufanout1div = ((Read(0x59) >> 0) & 3) | (((Read(0x4c) >> 7) & 1) << 2);
                cpufanout1rpm = GetRPM(cpufanout1, cpufanout1div);

                Debug.Assert(cpufanout1rpm < 100000);
            }

            failcount = 0;

            var vcore    = Read(0x20) * 0.008;
            var vin0_12v = Read(0x21) * 0.008 * 7; //guess
            //var avcc = Read(0x22) * 0.008;
            var vcc_3_3v = Read(0x23) * 0.008 * 2; //guess
            var vin1_5v  = Read(0x24) * 0.008 * 3; //guess

            //var vin2_2_5v = Read(0x25) * 0.008;
            //var vin3 = Read(0x26) * 0.008;

            Select(cs);

            yield return(Sample.Temperature("CPUTIN", cputin, true));

            yield return(Sample.Temperature("SYSTIN", systin, false));

            yield return(Sample.Temperature("AUXTIN", auxtin, true));

            if (motherboardtemp > 0)
            {
                yield return(Sample.Temperature("Motherboard", motherboardtemp, true));
            }

            yield return(Sample.FanSpeed("CPUFAN0", cpufanout0rpm, true));

            yield return(Sample.FanSpeed("CPUFAN1", cpufanout1rpm, true));

            yield return(Sample.FanSpeed("SYSFAN", sysfanoutrpm, true));

            yield return(Sample.FanSpeed("AUXFAN", auxfanout0rpm, true));

            yield return(Sample.Voltage("VCORE", vcore, true));

            yield return(Sample.Voltage("12V", vin0_12v, false));

            yield return(Sample.Voltage("5V", vin1_5v, false));

            yield return(Sample.Voltage("3.3V", vcc_3_3v, false));
        }