Re: [ctypes-users] allocating memory in Python and then coverting it into Physical memory
Brought to you by:
theller
From: Thomas H. <th...@ct...> - 2008-07-18 20:05:26
|
david elsen schrieb: > Hello all, > > I am trying to use (learn) Python in Linux environment and kind of > new to both. Know little bit about Linux, Python just started > yesterday. > > I am trying to write an application in Python which will be > allocating memory for my header and data buffer (header is a > structure pointer and data is an dword array pointer). Then need to > convert this virtual memory to physical memory and pass it on to the > IOCTL for further processing. > > Some DMA operation will be performed on this passed header and data > address. > > I was suggested that I can write am application in Python by using > CTYPES. > > I no not even know how can I load the CTYPES. I tried to follow the > documentation and did following: > > #Python Python 2.4.3 (#1, Dec 11 2006, 11:38:52) >>>>> cdll.LoadLibrary("libc.so.6") > NameError: name 'cdll' is not defined > I suggest you first start to play with Python. Forget your concrete problem for a while and work through the Python tutorial avaliable at www.python.org. Then you can turn to the ctypes tutorial again and try out ctypes (although I fear ctypes is not included in the Python 2.4 version that you have available); you would have to install it first. Then you wil lhave to decide whether to approach your problem with Python, C, or whatever language. ctypes is not really a trivial module. Finally, a hint for your question: You must first import the ctypes module before you can work with it; like so: >>> from ctypes import cdll >>> cdll.LoadLibrary("libc.so.6") Thomas |