Jump to content

Mother Board Monitor 5


Recommended Posts

Is there anyone that knows how to intercept the temps, and store them to variables? I need it for my LCD project.

Is there a way to use dllcalls or coms? I couldn't find any help on google or on the forums.

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Another added question, how do you all figure out a .dll's dll-structure?

Dim $pdwCoreTemp
Dim $pdwAmbientTemp
Dim $pdwUpperLimit
$nWindowsMonitorNumber = 1

$dll = DllOpen("nvcpl.dll")

$result = DllCall($dll,"int", "NvCplGetThermalSettings", "int",$nWindowsMonitorNumber, "long_ptr", $pdwCoreTemp, "long_ptr", $pdwAmbientTemp, "long_ptr", $pdwUpperLimit)
$Number = StringReplace($result[2], "|", @CRLF)

$Temp = $Number * 1.8 + 32
MsgBox(4096, "Test",$Temp)

DllClose($dll)

I found the .dll structure so I could do that, I can't do anything with Mbm5 because no one has a .dll structure.

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Is there anyway someone could help me with this source? This is MBM5 source, I wanted to know how to use auto's 'com' system to read sensor temps.

/////////////////////////////////////////////////////////////////////////////
//  File     : mbm.hpp
//  Date     : Octobre 13, 2003
//  Author   : Danny Couture
//    Mail : dcouture@popupsolutions.com
//  Version  : 1.0
//  Desc     : C++ wrapper for MotherBoard Monitor Shared Memory Access
//
/////////////////////////////////////////////////////////////////////////////
//
//  Date     : December 12, 2003
//  Author   : Maurizio Bonesi
//    Mail : maurizio.bonesi@it.datalogic.com
//  Version  : 1.1
//  Desc     : Added several methods for direct sensor access through mbm object.
//           Introduced several #defines for data structures length for an easier
//           class expansion or customization

#ifndef MBM_HPP
#define MBM_HPP

#include <windows.h>
#include <string>

namespace mbm {

#define NOTFOUND_STRING      "not_found"

#define BT_ISA        "type_isa"
#define BT_SMBUS        "type_smbus"
#define BT_VIA686ABUS   "type_via686abus"
#define BT_DIRECTIO  "type_directio"
#define BT_UNKNOWN    "type_unknown"
typedef enum { btISA = 0, btSMBus, btVIA686ABus, btDirectIO } bus_t;

#define SMBT_INTEL  "type_intel"
#define SMBT_AMD    "type_amd"
#define SMBT_ALI    "type_ali"
#define SMBT_NFORCE "type_nforce"
#define SMBT_SIS    "type_sis"
#define SMBT_UNK    BT_UNKNOWN
typedef enum { smtSMBIntel = 0, smtSMBAMD, smtSMBALi, smtSMBNForce, smtSMBSIS } smb_t;

#define ST_UNKNOWN    BT_UNKNOWN
#define ST_TEMPERATURE  "type_temperature"
#define ST_VOLTAGE    "type_voltage"
#define ST_FAN        "type_fan"
#define ST_MHZ        "type_mhz"
#define ST_PERCENTAGE   "type_percentage"
typedef enum { stUnknown = 0, stTemperature, stVoltage, stFan, stMhz, stPercentage } sensor_t;


/* centralize #defines here for portability and upgradability */
#define SENSOR_INDEX_LENGTH 10
#define SENSOR_INFO_LENGTH  100

#define SENSOR_NAME_LEN  12
#define TIME_STRING_LENGTH  41
#define MBM_PATHNAME_LENGTH 256

#define SMBUSNAME_STRING_LENGTH 41

#define PADDING1_SIZE_BYTES 3   
#define PADDING2_SIZE_BYTES 4
#define PADDING3_SIZE_BYTES 8

#define VERSION_STRING_LENGTH      4
#define VERSION_STRING_SEPARATOR_CH '.'

template <typename T>
void flush(const T & val)
{
    FlushViewOfFile(&val, sizeof(val));
}

#pragma pack(push, 1)

class index
{
private:
    int        _type;                  // type of sensor
    int        _count;                // number of sensor for that type

public:
    sensor_t type() const { return (sensor_t)_type; }
    int count()  const { return _count; }
};

class sensor
{
private:
    char           _type;                          // type of sensor
    char           _name[SENSOR_NAME_LEN];        // name of sensor
    char           _padding1[PADDING1_SIZE_BYTES];  // padding of 3 byte
    double       _current;                      // current value
    double       _low;                          // lowest readout
    double       _high;                        // highest readout
    long           _readout;                        // total number of readout
    char           _padding2[PADDING2_SIZE_BYTES];  // padding of 4 byte
    long double _total;                       // total amout of all readouts
    char           _padding3[PADDING3_SIZE_BYTES];  // padding of 6 byte
    double       _alarm1;                        // temp & fan: low alarm; voltage: % off;
    double       _alarm2;                        // temp: high alarm

public:
    sensor_t type() const { return (sensor_t)_type; }
    void type(sensor_t type) { _type = (char)type; flush(_type); }

    std::string name() const { return std::string(_name); }
    void name(const std::string & name) { strncpy(_name, name.c_str(), sizeof(_name)); flush(_name); }

    double current() const { return _current; }
    void current(double current) { _current = current; flush(_current); }

    double low() const { return _low; }
    void low(double low) { _low = low; flush(_low); }

    double high() const { return _high; }
    void high(double high) { _high = high; flush(_high); }

    long readout() const { return _readout; }
    void readout(long readout) { _readout = readout; flush(_readout); }

    double alarm1() const { return _alarm1; }
    void alarm1(double alarm1) { _alarm1 = alarm1; flush(_alarm1); }

    double alarm2() const { return _alarm2; }
    void alarm2(double alarm2) { _alarm2 = alarm2; flush(_alarm2); }
};

class info
{
private:
    short         _smbBase;                         // SMBus base address
    bus_t         _smbType;                         // SMBus/Isa bus used to access chip
    smb_t         _smbCode;                         // SMBus sub type, Intel, AMD or ALi
    char           _smbAddr;                            // Address of sensor chip on SMBus
    char           _smbName[SMBUSNAME_STRING_LENGTH];   // Nice name for SMBus
    short         _isaBase;                         // ISA base address of sensor chip on ISA
    int         _chipType;                         // Chip nr, connects with Chipinfo.ini
    char           _voltageSubType;                  // Subvoltage option selected

public:

    short         smbBase()     const { return _smbBase; }
    bus_t         smbType()     const { return _smbType; }
    smb_t         smbCode()     const { return _smbCode; }

    char           smbAddr()        const { return _smbAddr; }
    std::string smbName()       const { return std::string(_smbName); }
    short         isaBase()     const { return _isaBase; }
    int         chipType()     const { return _chipType; }
    char           voltageSubType() const { return _voltageSubType; }
};

#pragma pack(pop)

class mbm
{
private:
    #pragma pack(push, 1)
        struct data_t
        {
            double       _version;                  // version number (example: 51090)
            index         _index[SENSOR_INDEX_LENGTH]; // Sensor index
            sensor       _sensor[SENSOR_INFO_LENGTH]; // sensor info
            info           _info;                      // misc. info
            unsigned char  _start[TIME_STRING_LENGTH];  // start time
            unsigned char  _current[TIME_STRING_LENGTH];// current time
            unsigned char  _path[MBM_PATHNAME_LENGTH];  // MBM path
        };
    #pragma pack(pop)

    data_t *    data;
    HANDLE    mbmMemory;

    int      totSensors;
    std::string v;

public:
    mbm()
        : data(0), mbmMemory(0), totSensors(0), v()
    {
    }

    ~mbm()
    {
        close();
    }

    bool open()
    {
        char        strTmp[VERSION_STRING_LENGTH + ((VERSION_STRING_LENGTH-1)*sizeof(VERSION_STRING_SEPARATOR_CH)) ];

        if (opened()) 
            return true;

        // try to open shared memory
        if (mbmMemory == 0)
            mbmMemory = OpenFileMapping(FILE_MAP_WRITE, FALSE, "$M$B$M$5$S$D$");

        if (mbmMemory == 0)
            return false;

        data = (data_t *)MapViewOfFile(mbmMemory, FILE_MAP_WRITE, 0, 0, 0);
        for(int j=0; j<SENSOR_INDEX_LENGTH; j++) 
                    totSensors += (data->_index[j]).count();            

        //format version string
        sprintf(strTmp, "%g", data->_version);
        v.assign(strTmp);
        for(int i=0; i<VERSION_STRING_LENGTH-1; i++) 
            v.insert((i<<1)+1, std::string(1,VERSION_STRING_SEPARATOR_CH));
        
        return opened();
    }

    bool opened() const { return data != 0; }

    void close()
    {
        if (data != 0)
        {
            UnmapViewOfFile(data);
            data = 0;
        }

        if (mbmMemory != 0)
        {
            CloseHandle(mbmMemory);
            mbmMemory = 0;
        }
    }

    double    version() const        { return data->_version; }
    std::string version_string() const  { return v; }
    std::string path()  const        { return std::string((char*)data->_path); }

    index  *    index()      { return data->_index; }
    sensor *    sensor()        { return data->_sensor; }   
    const int   tot_sensors()   { return totSensors; }

    /* 
        Methods for accessing MBM properties and 
        retrieve a std::string out of them
    */
    std::string bus_type(void) const { 
        switch((data->_info).smbType()) {
        case btISA:
            return std::string(BT_ISA);
            break;
        case btSMBus:
            return std::string(BT_SMBUS);
            break;
        case btVIA686ABus:
            return std::string(BT_VIA686ABUS);
            break;
        case btDirectIO:
            return std::string(BT_DIRECTIO);
            break;
        default:
            return std::string(BT_UNKNOWN);
            break;
        }
    }
    std::string smb_name(void) const { return (data->_info).smbName(); }    
    std::string smb_type(void) const { 
        switch((data->_info).smbCode()) {
        case smtSMBIntel:
            return std::string(SMBT_INTEL);
            break;
        case smtSMBAMD:
            return std::string(SMBT_AMD);
            break;
        case smtSMBALi:
            return std::string(SMBT_ALI);
            break;
        case smtSMBNForce:
            return std::string(SMBT_NFORCE);
            break;
        case smtSMBSIS:
            return std::string(SMBT_SIS);
            break;
        default:
            return std::string(SMBT_UNK);
            break;
        }
    }
    /*
        methods for retrieving a sensor property 
        directly from the mbm object instance just 
        by passing the sensor's string name
    */
    sensor_t type(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).type();
        }
        return stUnknown; 
    }
    std::string sensor_type(const std::string & n) const { 
        //retrieves a string with the sensor type 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                switch((data->_sensor[j]).type()) {
                case stTemperature:
                    return std::string(ST_TEMPERATURE);
                    break;
                case stVoltage:
                    return std::string(ST_VOLTAGE);
                    break;
                case stFan:
                    return std::string(ST_FAN);                 
                    break;
                case stMhz:
                    return std::string(ST_MHZ);                 
                    break;
                case stPercentage:
                    return std::string(ST_PERCENTAGE);                  
                    break;
                case stUnknown:
                default:
                    break;
                }
        }
        return std::string(ST_UNKNOWN);
    }
    double current(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).current();
        }
        return 0; 
    }
    double high(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).high();
        }
        return 0; 
    }
    double low(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).low();
        }
        return 0; 
    }
    long readout(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).readout();
        }
        return 0; 
    }
    double alarm1(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).alarm1();
        }
        return 0; 
    }
    double alarm2(const std::string & n) const { 
        for(int j=0; j<totSensors; j++) {
            if( (data->_sensor[j]).name() == n)
                return (data->_sensor[j]).alarm2();
        }
        return 0; 
    }
};

}   //namespace mbm

#endif  //MBM_HPP

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...