diff options
Diffstat (limited to 'xpa/python/PythonXPA/client')
-rw-r--r-- | xpa/python/PythonXPA/client/XPAClient.py | 98 | ||||
-rwxr-xr-x | xpa/python/PythonXPA/client/test_XPAC.py | 104 |
2 files changed, 0 insertions, 202 deletions
diff --git a/xpa/python/PythonXPA/client/XPAClient.py b/xpa/python/PythonXPA/client/XPAClient.py deleted file mode 100644 index 29e39eb..0000000 --- a/xpa/python/PythonXPA/client/XPAClient.py +++ /dev/null @@ -1,98 +0,0 @@ - -import sys -from ctypes import * - -libxpa=cdll.LoadLibrary("../../libxpa.so.1.0") -libc=cdll.LoadLibrary(None); - - -#xpa_t = c_void_p -#xpa = xpa_t(None) - -c_byte_p = POINTER(c_byte) - - - -############## - -NXPA = 10 - -############## - - -def free_bufs(p_arr, len): - for i in range(len): - if p_arr[i]: - print "freeing [", i, "] ", p_arr[i][0], p_arr[i][1] - libc.free(p_arr[i]) - - - - - -## XPA XPAOpen(char *mode); - -XPAOpen = libxpa.XPAOpen -libxpa.XPAOpen.restype = c_void_p -libxpa.XPAOpen.argtypes = [c_char_p] - -## void XPAClose(XPA xpa); -XPAClose = libxpa.XPAClose -libxpa.XPAClose.argtypes = [c_void_p] - - -## int XPAGet(XPA xpa, char *template, char *paramlist, char *mode, -## char **bufs, int *lens, char **names, char **messages, int n); - -XPAGet = libxpa.XPAGet -libxpa.XPAGet.restype = c_int -libxpa.XPAGet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \ - c_byte_p*NXPA, c_int*NXPA, c_byte_p*NXPA, c_byte_p*NXPA, \ - c_int] - - -## when you want to send something like "hello\0x00 you" use this - -## int XPASet(XPA xpa, -## char *template, char *paramlist, char *mode, -## char *buf, int len, char **names, char **messages, -## int n); - -#libxpa.XPASet.restype = c_int -#libxpa.XPASet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \ -# c_byte_p, c_int, c_char_p*NXPA, c_char_p*NXPA, \ -# c_int] - -## when you know, you will send strings only, use this one to avoid conversions - -XPASet = libxpa.XPASet -libxpa.XPASet.restype = c_int -libxpa.XPASet.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \ - c_char_p, c_int, c_byte_p*NXPA, c_byte_p*NXPA, \ - c_int] - -## int XPAInfo(XPA xpa, -## char *template, char *paramlist, char *mode, -## char **names, char **messages, int n); - -XPAInfo = libxpa.XPAInfo -libxpa.XPAInfo.restype = c_int -libxpa.XPAInfo.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \ - c_byte_p*NXPA, c_byte_p*NXPA, \ - c_int] - -## int XPAAccess(XPA xpa, -## char *template, char *paramlist, char *mode, -## char **names, char **messages, int n); - -XPAAccess = libxpa.XPAAccess -libxpa.XPAAccess.restype = c_int -libxpa.XPAAccess.argtypes = [c_void_p, c_char_p, c_char_p, c_char_p, \ - c_byte_p*NXPA, c_byte_p*NXPA, \ - c_int] - -#del libxpa - - - - diff --git a/xpa/python/PythonXPA/client/test_XPAC.py b/xpa/python/PythonXPA/client/test_XPAC.py deleted file mode 100755 index 7111a98..0000000 --- a/xpa/python/PythonXPA/client/test_XPAC.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/python - -################################ -####### testing: # -####### please start "stest" # -################################ - -from XPAClient import * - -import time - -xpa = None -print xpa -xpa = XPAOpen("ack=false") -############################ -print xpa - -buff_t = c_byte_p*NXPA - -buffs = buff_t() -names = buff_t() -messages = buff_t() - - - -int_t = c_int*NXPA -lens = int_t() - -ok = True -while ok: - #ok = False - print "--- XPAGet Test 1" - n = XPAGet(xpa, "XPA:xpa*", "help", "ack=false", buffs, lens, names, \ - messages, NXPA) - ######################################################################### - print n - print buffs[0][0:lens[0]], "\n", buffs[1][0:lens[1]] - print string_at(names[0]), string_at(names[1]) - - for j in range(n): - ascii_text = string_at(buffs[j], lens[j]) - #ascii_text = ''.join(chr(buffs[j][i]) for i in range(0, lens[j])) - print "---", j, "---\n>>>\n" + ascii_text + "\n<<<" - - free_bufs(buffs, NXPA) - free_bufs(names, NXPA) - free_bufs(messages, NXPA) - - - print "--- XPASet Test 1" - txt = "Hey, you!" - n = XPASet(xpa, "XPA:xpa", "", "", txt, len(txt), names, messages, NXPA) - ######################################################################### - print string_at(names[0]) - free_bufs(names, NXPA) - free_bufs(messages, NXPA) - - #sys.exit(0) - - print "--- XPAGet Test 2" - n = XPAGet(xpa, "XPA:xpa[12]", "error", "", buffs, lens, names, \ - messages, NXPA) - ######################################################################### - print n - print ":::: " - if names[0]: - print "\t names[0]: ", string_at(names[0]) - if names[1]: - print "\t names[1]: ", string_at(names[1]) - - free_bufs(buffs, NXPA) - free_bufs(names, NXPA) - free_bufs(messages, NXPA) - - print "--- XPAInfo Test 1" - n = XPAInfo(xpa, "XPA:i_xpa", "hey there", "", names, messages, NXPA) - ######################################################################### - print n - if names: - free_bufs(names, NXPA) - if messages: - free_bufs(messages, NXPA) - - n = XPAAccess(xpa, "XPA:*", "", "", names, messages, NXPA) - ######################################################################### - print n - for j in range(n): - print "access ---", j, "--- >>>" + string_at(names[j]) + "<<<" - - if names: - free_bufs(names, NXPA) - if messages: - free_bufs(messages, NXPA) - - - - #time.sleep(0.010) - - - -XPAClose(xpa) -############### -xpa = None - |