Re: Problem with access to shared memory(W2K) / ORIGINALLY (win32) speedfan api control



Thomas Heller,
it seems, that your email address
theller@xxxxxxxxxx doesn't work
or at least don't accept attachments,
so maybe you can provide me with
another one?

> ptr = cast(pBuf, POINTER(Buffer))
> print ptr # should print <ctypes.LP_Buffer object at ...>
> struct = ptr[0]

results in breakdown of Python
(Windows exception, can't read from memory
at 0x0...07)
due to existance of
> ptr = cast(pBuf, POINTER(Buffer))
but the print
> print ptr # should print <ctypes.LP_Buffer object at ...>
does its output to the console...

Strange...

Claudio

"Thomas Heller" <theller@xxxxxxxxxx> schrieb im Newsbeitrag
news:y8bvy7vd.fsf@xxxxxxxxxxxxx
> "Claudio Grondi" <claudio.grondi@xxxxxxxxxx> writes:
>
> >> For the mistake you made see below, hope that helps.
> > It doesn't.
> >
> >> > 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.
> > If I currently understand it right, cast() should
> > do exactly this, i.e. should write the content
> > pointed to by pBuf to a Python variable
> > pBuf_buf which is an object of the Buffer
> > class, where I can access the single
> > components like any other Python
> > variables - am I right or wrong?
>
> You are right - my bad.
> pBuf is a pointer to your structure, so:
>
> ptr = cast(pBuf, POINTER(Buffer))
> print ptr # should print <ctypes.LP_Buffer object at ...>
> struct = ptr[0]
>
> and now 'struct' should contain the data that you need.
>
> >> 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 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)
> >
> > So I am already using the recipe, right?
> > But it doesn't work as expected.
> > mmap doesn't work at all failing in
> > shmem = mmap.mmap(0, 0, "$M$B$M$5$S$D$", mmap.ACCESS_READ)
> > with WindowsError: [Errno 87] wrong parameter
>
> I get this error when I try to open a non-existing shared memory block.
> From the mmap docs:
>
> If length is 0, the maximum length of the map is the current size of
> the file, except that if the file is empty Windows raises an exception
> (you cannot create an empty mapping on Windows).
>
> If I run it with non-zero length it does not raise an exception
>
> shmem = mmap.mmap(0, 0, "$M$B$M$5$S$D$", mmap.ACCESS_READ)
>
> although it *creates* the shared memory block, IIUC. Are you sure your
> speedfan app is running when you get the WindowsError?
>
> Thomas


.



Relevant Pages

  • Re: inconnectivity between windows ce and eCos
    ... I think that what you want is to know how to manage the shared memory. ... For the Windows CE CPU and your applications, you just need to make the ... > processor windows ce is running and in other processor eCOS is running, ... >> devices that happen to be running different operating systems? ...
    (microsoft.public.windowsce.platbuilder)
  • Re: need a way
    ... Now the last question,,, The shared memory system I am going to build needs ... In Windows terms, each application that is ... > efficient way, in Windows, is of course Windows Messaging. ... > means that your MainA has a single thread, ...
    (microsoft.public.dotnet.languages.vc)
  • Re: need a way
    ... The second thing you need is some sort of a messaging system. ... efficient way, in Windows, is of course Windows Messaging. ... MainB uses the shared memory access to get data from the shared memory ... MainC is responsible for sending the WM_CUSTOM_REFRESH_DATA to MainA. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Problem with access to shared memory(W2K) / ORIGINALLY (win32) speedfan api control
    ... pBuf is a pointer to a Buffer structure, ... > access a shared memory area with a certain name also with Python's mmap ...
    (comp.lang.python)