Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


SMBUS access from C/C++ in Windows XP

Posted on 2006-05-31
Medium Priority
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
  • 2
  • 2

Expert Comment

ID: 16799795
Unless you find a driver that runs C++ to Assembly, you're going to be talking to it in assembly.  http://www.smbus.org/specs/smbus20.pdf 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.  http://www2.lm-sensors.nu/~lm78/cvs/browse.cgi/lm_sensors2

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

Author Comment

ID: 16804093
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.

Accepted Solution

gran88 earned 2000 total points
ID: 16809381
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.

Author Comment

ID: 16857852
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

ID: 27783541
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Six Sigma Control Plans
Loops Section Overview

569 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