D
digitnctu
Dear all:
I am coming with problem, to apply ctypes under interactive mode
in python.
libdll.dll is a third-party library. The below code segment will
run well under the batch mode(ie. python test.py 11060)
but when I type sequencially it doesn't work as usual. Can any
give me a hand??
# file test.py begin
from ctypes import *
lib = CDLL("libdll.dll")
def evCb(ev, clData, caData):
print "event: ", ev,"=>" , string_at(caData)
def run(port):
libinf = lib.libCreate(0)
lib.libConnect(libinf,port,0,0)
evfptr = CFUNCTYPE(None,c_char_p, c_void_p,c_void_p)
lib.libCltAddEventCallback(libinf,"AllEvents",evfptr(evCb),0)
result = c_char_p()
libbuf = raw_input("lib>")
while libbuf != "quit":
lib.libCallCommand(libinf,libbuf,0,pointer(result))
print "result: ",result.value
if libbuf == "Exit":
break
libbuf = raw_input("lib>")
lib.libDestroy(libinf)
if __name__ == "__main__":
import sys,string
run(string.atoi(sys.argv[1]))
# file test.py end
I type in interactive mode of python as below:
from ctypes import *
lib = CDLL("libdll.dll")
def evCb(ev,clData,caData):
print "event: ", ev,"=>" , string_at(caData)
libinf = lib.libCreate(0)
lib.libConnect(libinf, 11060, 0,0)
evfptr = CFUNCTYPE(None,c_char_p, c_void_p,c_void_p)
lib.libCltAddEventCallback(libinf,"AllEvents",evfptr(evCb),0)
result = c_char_p()
lib.libCallCommand(libinf,"somecmd",0,pointer(result))
lib.libDestroy(libinf)
I am coming with problem, to apply ctypes under interactive mode
in python.
libdll.dll is a third-party library. The below code segment will
run well under the batch mode(ie. python test.py 11060)
but when I type sequencially it doesn't work as usual. Can any
give me a hand??
# file test.py begin
from ctypes import *
lib = CDLL("libdll.dll")
def evCb(ev, clData, caData):
print "event: ", ev,"=>" , string_at(caData)
def run(port):
libinf = lib.libCreate(0)
lib.libConnect(libinf,port,0,0)
evfptr = CFUNCTYPE(None,c_char_p, c_void_p,c_void_p)
lib.libCltAddEventCallback(libinf,"AllEvents",evfptr(evCb),0)
result = c_char_p()
libbuf = raw_input("lib>")
while libbuf != "quit":
lib.libCallCommand(libinf,libbuf,0,pointer(result))
print "result: ",result.value
if libbuf == "Exit":
break
libbuf = raw_input("lib>")
lib.libDestroy(libinf)
if __name__ == "__main__":
import sys,string
run(string.atoi(sys.argv[1]))
# file test.py end
I type in interactive mode of python as below:
from ctypes import *
lib = CDLL("libdll.dll")
def evCb(ev,clData,caData):
print "event: ", ev,"=>" , string_at(caData)
libinf = lib.libCreate(0)
lib.libConnect(libinf, 11060, 0,0)
evfptr = CFUNCTYPE(None,c_char_p, c_void_p,c_void_p)
lib.libCltAddEventCallback(libinf,"AllEvents",evfptr(evCb),0)
result = c_char_p()
lib.libCallCommand(libinf,"somecmd",0,pointer(result))
lib.libDestroy(libinf)