1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
| #!/usr/bin/python
| # -*- coding: GBK -*-
| #×÷Õß :
|
| import CommFunc
| import binascii
| import copy
| from struct import *
| from ctypes import *
| #²å¼þÍ·
| #
| #
| ChNetPackDict={}
| class BString:
| NameLen = 0 # (BYTE NameLen )
| Name = "" # (String Name ) //size = NameLen
| data = None
|
| def __init__(self):
| self.Clear()
|
| return
| def ReadData(self, _lpData, _pos=0, _Len=0):
| self.Clear()
|
| self.NameLen, _pos = CommFunc.ReadBYTE(_lpData, _pos)
| self.Name, _pos = CommFunc.ReadString(_lpData, _pos, self.NameLen)
|
| return _pos
|
| def Clear(self):
| self.NameLen = 0
| self.Name = ""
| return
|
| def GetLength(self):
| length = 0
| length += 1
| length += self.Name.Length()
| return length
|
| def GetBuffer(self):
| data = ''
| data = CommFunc.WriteBYTE(data, self.NameLen)
| data = CommFunc.WriteString(data, self.NameLen, self.Name)
| return data
|
| def OutputString(self):
| DumpString = ''':
| NameLen:%d,
| Name:%s
| '''\
| %(
| self.NameLen,
| self.Name
| )
|
| return DumpString
|
| class tagHead:
| Cmd = 0 # (BYTE Cmd )
| SubCmd = 0 # (BYTE SubCmd )
| def __init__(self):
| self.Clear()
|
| return
| def ReadData(self, _lpData, _pos=0, _Len=0):
| self.Clear()
|
| self.Cmd, _pos = CommFunc.ReadBYTE(_lpData, _pos)
| self.SubCmd, _pos = CommFunc.ReadBYTE(_lpData, _pos)
|
| return _pos
|
| def Clear(self):
| self.Cmd = 0
| self.SubCmd = 0
| return
|
| def GetLength(self):
| length = 0
| length += 1
| length += 1
| return length
|
| def GetBuffer(self):
| data = ''
| data = CommFunc.WriteBYTE(data, self.Cmd)
| data = CommFunc.WriteBYTE(data, self.SubCmd)
| return data
|
| def OutputString(self):
| DumpString = ''':
| Cmd:%d,
| SubCmd:%d
| '''\
| %(
| self.Cmd,
| self.SubCmd
| )
|
| return DumpString
| #------------------------------------------------------
| # C2 01 ¿ç·þ·þÎñÆ÷¼äµÄ²âÊÔ°ü #tagSSTest
|
| class tagSSTest(Structure):
| _pack_ = 1
| _fields_ = [
| ("Cmd", c_ubyte),
| ("SubCmd", c_ubyte),
| ("Data", c_int), #²âÊÔ
| ]
|
| def __init__(self):
| self.Clear()
| self.Cmd = 0xC2
| self.SubCmd = 0x01
| return
|
| def ReadData(self, stringData, _pos=0, _len=0):
| self.Clear()
| memmove(addressof(self), stringData[_pos:], self.GetLength())
| return _pos + self.GetLength()
|
| def Clear(self):
| self.Cmd = 0xC2
| self.SubCmd = 0x01
| self.Data = 0
| return
|
| def GetLength(self):
| return sizeof(tagSSTest)
|
| def GetBuffer(self):
| return string_at(addressof(self), self.GetLength())
|
| def OutputString(self):
| DumpString = '''// C2 01 ¿ç·þ·þÎñÆ÷¼äµÄ²âÊÔ°ü //tagSSTest:
| Cmd:%s,
| SubCmd:%s,
| Data:%d
| '''\
| %(
| self.Cmd,
| self.SubCmd,
| self.Data
| )
| return DumpString
|
|
| m_NAtagSSTest=tagSSTest()
| ChNetPackDict[eval("0x%02x%02x"%(m_NAtagSSTest.Cmd,m_NAtagSSTest.SubCmd))] = m_NAtagSSTest
|
|