author | Laurent Bessard |
Thu, 25 Oct 2012 19:56:48 +0200 | |
changeset 869 | abf90a44c265 |
parent 862 | bb59865db6e6 |
child 1067 | 4f460c1dffb5 |
permissions | -rw-r--r-- |
366
cd90e4c10261
Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff
changeset
|
1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
728
e0424e96e3fd
refactoring - library support is not anymore attached to configtree nodes, but handles by project controller
Edouard Tisserant
parents:
721
diff
changeset
|
2 |
<Python xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="py_ext_xsd.xsd"> |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
3 |
<![CDATA[import time,sys,ctypes |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
4 |
Python_to_C_Call = PLCBinary.Python_to_C_Call |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
5 |
Python_to_C_Call.restype = ctypes.c_int |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
6 |
Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)] |
734 | 7 |
|
8 |
def MyPythonFunc(arg): |
|
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
9 |
i = ctypes.c_int() |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
10 |
if(Python_to_C_Call(arg, i)): |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
11 |
res = i.value |
862
bb59865db6e6
Introduced FBID in tests/python example. Fixed type error leading to segfault
Edouard Tisserant
parents:
859
diff
changeset
|
12 |
print "toC:", arg, "from C:", res, "FBID:", FBID |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
13 |
else: |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
14 |
print "Failed Python_to_C_Call failed" |
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
15 |
res = None |
366
cd90e4c10261
Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff
changeset
|
16 |
sys.stdout.flush() |
859
dbf82971f09d
More pedagogical tests/python. Should be renamed python_ctypes_and_C_pragmas_in_ST or something
Edouard Tisserant
parents:
734
diff
changeset
|
17 |
return res |
734 | 18 |
]]> |
366
cd90e4c10261
Move python evaluator to create a python plugin containing any related python module
laurent
parents:
diff
changeset
|
19 |
</Python> |