Add support of object type "arr" (array) in protocol

This commit is contained in:
Sebastien Helleu 2012-07-20 18:19:11 +02:00
parent eafb7aebb2
commit 4b44d000ee

View file

@ -108,6 +108,7 @@ class Protocol:
'hda': self._obj_hdata, 'hda': self._obj_hdata,
'inf': self._obj_info, 'inf': self._obj_info,
'inl': self._obj_infolist, 'inl': self._obj_infolist,
'arr': self._obj_array,
} }
def _obj_type(self): def _obj_type(self):
@ -250,6 +251,15 @@ class Protocol:
items.append(variables) items.append(variables)
return {'name': name, 'items': items} return {'name': name, 'items': items}
def _obj_array(self):
"""Read an array of values in data."""
type_values = self._obj_type()
count_values = self._obj_int()
values = []
for i in range(0, count_values):
values.append(self._obj_cb[type_values]())
return values
def decode(self, data): def decode(self, data):
"""Decode binary data and return list of objects.""" """Decode binary data and return list of objects."""
self.data = data self.data = data