ctypes question
MrJean1
mrjean1 at gmail.com
Tue Dec 14 19:47:05 EST 2010
Try again after changing line 16 to
sn = SmiGetNode(None, "1.3.6.1.2.1.2.2")
Because, SmiGetNode is a Python function which accepts Python objects
as arguments. Passing is a ctypes object oid is incorrect.
/Jean
On Dec 14, 10:36 am, News Wombat <newswom... at gmail.com> wrote:
> On Dec 11, 12:59 pm, MrJean1 <mrje... at gmail.com> wrote:
>
> > In general, for shared libraries, you need to define those first as
> > prototype using ctypes.CFUNCTYPE() and then instantiate each prototype
> > once supplying the necessary parameter flags using
> > prototype(func_spec, tuple_of_param_flags). See sections 15.16.2.3
> > and 4 of the ctypes docs*.
>
> I tried the cfuntype and proto steps, and it's not crashing now
> (that's good), but now i'm just left with null pointers as a return
> object. I'm still working through all of the examples you sent. They
> were extremely helpful. Here's where I'm at now...
>
> What is strange is I can actually get smiGetNode to work if I don't
> cfunctype/proto it. If i do, nada. however, the smiGetNextNode fails
> no matter what, usually with a segfault, but depending on how i
> construct it, sometimes a null pointer.
>
> constants.py:http://pastebin.com/f3b4Wbf0
> libsmi.py:http://pastebin.com/XgtpG6gr
> smi.c (the actual function):http://pastebin.com/Pu2vabWM
More information about the Python-list
mailing list