"Claudio Grondi" <[EMAIL PROTECTED]> writes: > Background information: > --------------------------------- > in order to monitor mainboard sensory data > as fan speeds, temperatures, applications > like SpeedFan http://www.almico.com/speedfan.php > or MBM http://mbm.livewiredev.com/ > can be used. > Both of the mentioned apps expose data got > from the hardware in a shared memory area. > > The goal to achieve: > --------------------------- > is to supervise the motherboard sensory > data from within a Python script > > The approach: > ------------------- > access to the shared memory area > exposed by motherboard hardware > querying apps from Python script.
For the mistake you made see below, hope that helps. For the general way to solve this problem you should know that you can access a shared memory area with a certain name also with Python's mmap module, although that is probably not documented very good. There was a recipe posted a few days ago which showed different ways to acces shared memory, with or without ctypes. > The problem: > ----------------- > the below listed script code returns > always same values, what > leads to the conclusion, that something > is going wrong. > > Can anyone help? > > Thanks in advance > > Claudio > > The code > ------------- > I use is provided also here: > http://www.codecomments.com/Python/message430495.html > http://mail.python.org/pipermail/python-list/2005-March/271853.html > (the mmap part of it doesn't work at all) > > from ctypes import * > > class Buffer(Structure): > # just to see if any useful data can be acquired > _fields_ = [ > ("Data0", c_longlong) > ,("Data1", c_longlong) > ,("Data2", c_longlong) > ,("Data3", c_longlong) > ,("Data4", c_longlong) > ,("Data5", c_longlong) > ,("Data6", c_longlong) > ,("Data7", c_longlong) > ,("Data8", c_longlong) > ,("Data9", c_longlong) > ,("DataA", c_longlong) > ,("DataB", c_longlong) > ,("DataC", c_longlong) > ,("DataD", c_longlong) > ,("DataE", c_longlong) > ,("DataF", c_longlong) > ] > > szName = c_char_p("SFSharedMemory_ALM") # SpeedFan > szName = c_char_p("$M$B$M$5$S$D$") # MBM > # szName = c_char_p("blabla") # not existing shared memory > > FILE_MAP_ALL_ACCESS = 0xF001F > FALSE = 0 > > hMapObject = windll.kernel32.OpenFileMappingA( > FILE_MAP_ALL_ACCESS > ,FALSE > ,szName > ) > if (hMapObject == 0): > print "Could not open file mapping object" > raise WinError() > > pBuf = windll.kernel32.MapViewOfFile( > hMapObject > ,FILE_MAP_ALL_ACCESS > ,0 > ,0 > ,0 > ) > > if (pBuf == 0): > print "Could not map view of file" > raise WinError() > else: > print repr(pBuf) > print repr(hMapObject) > > pBuf_str = cast(pBuf, c_char_p) > print repr(pBuf_str.value) > print repr(pBuf_str) > > pBuf_buf = cast(pBuf, Buffer) Here's the problem. pBuf is a pointer to a Buffer structure, not the buffer structure itself. Something like pBuf_buf = Buffer.from_address(pBuf) may work. Thomas -- http://mail.python.org/mailman/listinfo/python-list