]>
git.saurik.com Git - apple/xnu.git/blob - tools/lldbmacros/usertaskdebugging/rsprotocol.py
fa4fc7a28f4b44cf0fb0ba7695e072819f314898
5 """represents a message of Remote serial protocol"""
6 def __init__(self
, data
):
7 super(Message
, self
).__init
__()
11 return "Message: %s" % (self
.data
)
14 #TODO need to parse data and unescape
17 def getRSPByteData(self
):
18 retval
= ''.join(['$',self
.data
,'#'])
22 checksum
= checksum
% 0x100
23 checksum_str
= "{:02x}".format(checksum
)
24 retval
+= checksum_str
28 def fromRSPByteData(cls
, bytedata
):
32 data_begin
= bytedata
.index('$')
33 data_end
= bytedata
.index('#')
35 logging
.error('Invalid bytedata considered as message %s' % bytedata
)
39 if data_begin
+ 1 >= data_end
:
40 logging
.debug("empty message %s"%bytedata
)
44 logging
.debug("Creating message from data %s" % bytedata
[data_begin
:data_end
])
45 ret_obj
= cls(bytedata
[data_begin
:data_end
])
48 class ProtocolAcknowledgement(Message
):
50 def __init__(self
, ack_str
):
51 super(ProtocolAcknowledgement
, self
).__init
__(ack_str
)
54 def getRSPByteData(self
):
58 OKMessage
= Message('OK')
60 AckMessage
= ProtocolAcknowledgement('+')
61 NAckMessage
= ProtocolAcknowledgement('-')
62 UnSupportedMessage
= Message('')