28 |
28 |
29 |
29 |
30 from ctypes import * |
30 from ctypes import * |
31 from datetime import timedelta as td |
31 from datetime import timedelta as td |
32 |
32 |
|
33 |
33 class IEC_STRING(Structure): |
34 class IEC_STRING(Structure): |
34 """ |
35 """ |
35 Must be changed according to changes in iec_types.h |
36 Must be changed according to changes in iec_types.h |
36 """ |
37 """ |
37 _fields_ = [("len", c_uint8), |
38 _fields_ = [("len", c_uint8), |
38 ("body", c_char * 126)] |
39 ("body", c_char * 126)] |
|
40 |
39 |
41 |
40 class IEC_TIME(Structure): |
42 class IEC_TIME(Structure): |
41 """ |
43 """ |
42 Must be changed according to changes in iec_types.h |
44 Must be changed according to changes in iec_types.h |
43 """ |
45 """ |
44 _fields_ = [("s", c_long), #tv_sec |
46 _fields_ = [("s", c_long), #tv_sec |
45 ("ns", c_long)] #tv_nsec |
47 ("ns", c_long)] #tv_nsec |
46 |
48 |
|
49 |
47 def _t(t, u=lambda x:x.value, p=lambda t,x:t(x)): return (t, u, p) |
50 def _t(t, u=lambda x:x.value, p=lambda t,x:t(x)): return (t, u, p) |
|
51 |
|
52 |
48 def _ttime(): return (IEC_TIME, |
53 def _ttime(): return (IEC_TIME, |
49 lambda x:td(0, x.s, x.ns/1000), |
54 lambda x:td(0, x.s, x.ns/1000), |
50 lambda t,x:t(x.days * 24 * 3600 + x.seconds, x.microseconds*1000)) |
55 lambda t,x:t(x.days * 24 * 3600 + x.seconds, x.microseconds*1000)) |
51 |
56 |
52 SameEndianessTypeTranslator = { |
57 SameEndianessTypeTranslator = { |
84 TypeTranslator=SameEndianessTypeTranslator |
89 TypeTranslator=SameEndianessTypeTranslator |
85 |
90 |
86 # Construct debugger natively supported types |
91 # Construct debugger natively supported types |
87 DebugTypesSize = dict([(key,sizeof(t)) for key,(t,p,u) in SameEndianessTypeTranslator.iteritems() if t is not None]) |
92 DebugTypesSize = dict([(key,sizeof(t)) for key,(t,p,u) in SameEndianessTypeTranslator.iteritems() if t is not None]) |
88 |
93 |
|
94 |
89 def UnpackDebugBuffer(buff, indexes): |
95 def UnpackDebugBuffer(buff, indexes): |
90 res = [] |
96 res = [] |
91 buffoffset = 0 |
97 buffoffset = 0 |
92 buffsize = len(buff) |
98 buffsize = len(buff) |
93 buffptr = cast(ctypes.pythonapi.PyString_AsString(id(buff)),c_void_p).value |
99 buffptr = cast(ctypes.pythonapi.PyString_AsString(id(buff)),c_void_p).value |