SMBUS access from C/C++ in Windows XP

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.

Steve.
LVL 3
steveiamAsked:
Who is Participating?
 
gran88Commented:
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.
0
 
gran88Commented:
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.
0
 
steveiamAuthor Commented:
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.
0
 
steveiamAuthor Commented:
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.
0
 
RajeevThoratCommented:
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.
Thanks,
Rajeev
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.