SMBUS access from C/C++ in Windows XP

Posted on 2006-05-31
Last Modified: 2012-06-27
Hi Experts,

I'm wanting to access SMBUS devices attached to my motherboard, preferably using C/C++ (MFC/.NET/Borland/whatever).  Initially I want to take readings from, and set parameters on, the temperature/fan controllers.  In the longer term, I want to access arbitrary SMBUS devices I attach to the bus (e.g. an 8-port I/O expander).  This will be run on a P3 or later hardware, if that's significant, with a variety of different motherboard chipsets (VIA, Intel, etc.)

I've done a lot of googling, and haven't found any clear or concise examples.

- The two solutions already here on EE (with premium access required) don't help.
- Using something like speedfan / motherboard monitor doesn't help, as I want my program to be able to access/control the bus (unless they have an API I can use?)
- If theres a DLL or similar available to do this, that's fine.
- A solution in any language would be ok, as I could wrap it up in an DLL and use that from my code.
- Use of stuff like GiveIO, privilege escalation software, etc., is fine
- Sensors on things like AGP video cards don't matter.  It's just the motherboard's SMBUS (and connector) I'm interested in.

Basically, I don't care how it gets done, but if I can end up reading/writing to (arbitrary) SMBUS devices, I'm happy.  Any code (complete or skeleton), or helpful pointers would be greatly appreciated.

Question by:steveiam
    LVL 2

    Expert Comment

    Unless you find a driver that runs C++ to Assembly, you're going to be talking to it in assembly. pretty much contains all the information you're going to need.

    LMSensors, if you havent run across them, wrote a few DLLs that read temperatures, and can talk to the buses.

    Sorting through their source code could help you out a bit.
    LVL 3

    Author Comment

    Writing stuff in assembly is fine.

    Had a look at the SMBus spec, and that only covers the SMBus protocol itself, not how to interface with it from within the Windows OS.  I assume that the SMBus is going to be at some I/O port, but as to how to find that out, and how to interact with it, I don't know.  I've used SMBus/I2C devices from embedded micros before, so the protocol/etc. isn't a problem.

    Had a look at lm_sensors , and I can only find Linux stuff.  Do you have a link directly to the DLL you mentioned?

    On Linux, lm_sensors is using /dev/i2c, which is provided by a kernel driver.  It isn't something available on Windows, and I haven't found a Windows equivalent.
    LVL 2

    Accepted Solution

    Nay, I cannot find a link to the dll.  There exists both systool and gkrellm (mainly linux) which are monitoring programs for windows, gkrellm employs lm-sensor (IIRC), and it was simply cross compiled for windows.  Good luck on your search, I was unable to turn anything else up besides Video Miniport I2C implimentation in the MSDN library.
    LVL 3

    Author Comment

    systool looks promising.. I'll have a closer look at that soon.  The gkrellm port to Windows is display only - it appears to connect to a Linux server for its data.

    I'm starting to suspect that the miniport approach might be the 'correct' way to do it, though it seems to be a lot of code to write for something so simple.

    Expert Comment

    Hi experts,
    This is not the solution I was expecting and disappointed.
    Why is it not possible to use CreateFile call to SMBus controller driver and send SMBus REquest as an IOCTL  to read/wrtie a particualr device on the SM bus?
    In my case I can open the device using CretaeFile " SMBUSP1" and get the handle to the device.
    I am looking for a sample code that will be bale to make the calls to SMBus driver to read a particular device.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
    This is an explanation of a simple data model to help parse a JSON feed
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now