hxp
2025-05-28 09fef77b16601ee5b0f53f34ccb23804b8448c8c
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
 
#·â°üÏà¹ØµÄ¹«¹²¶¨Òå
 
from ctypes import (Structure, c_ubyte, memmove, string_at, sizeof, addressof)
 
 
class  tagHead(Structure):
    _pack_ = 1
    _fields_ = [
                  ("Cmd", c_ubyte),    
                  ("SubCmd", c_ubyte),    
                  ]
 
    def __init__(self):
        self.Clear()
        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 = 0
        self.SubCmd = 0
        return
 
    def GetLength(self):
        return sizeof(tagHead)
 
    def GetBuffer(self):
        return string_at(addressof(self), self.GetLength())
 
    def OutputString(self):
        DumpString = '''
                                Cmd:%d,
                                SubCmd:%d
                                '''\
                                %(
                                self.Cmd,
                                self.SubCmd
                                )
        return DumpString