mise à jour 13.11.3

Commit 02fd69de authored by aleajactaest's avatar aleajactaest
Browse files

adding yaml output

parent 63efd10d
This diff is collapsed.
......@@ -517,7 +517,7 @@ class BitStream():
self._groupWrite.append((p1, p2, name, 'BitStream', ''))
# ------------------------------------
def readSerial(self, nbits, name="", decode=True, typeName='', emulate=False):
def readSerial(self, nbits, name="", decode=True, typeName='', emulate=False, signed=False):
v1 = self._read
if nbits == 0:
return
......@@ -543,6 +543,8 @@ class BitStream():
if emulate:
self._read = oldRead
if decode and not emulate:
if signed:
value = c_int32(value).value
self._groupRead.append((v1, v1+nbits, name, typeName, value))
return value
......@@ -560,7 +562,7 @@ class BitStream():
return v
def readSint32(self, name, decode=True):
v = self.readSerial(32, name=name, decode=decode, typeName='Sint32')
v = self.readSerial(32, name=name, decode=decode, typeName='Sint32', signed=True)
return c_int32(v).value
def readUint16(self, name, decode=True):
......@@ -568,7 +570,7 @@ class BitStream():
return v
def readSint16(self, name):
v = self.readSerial(16, name=name, typeName='Sint16')
v = self.readSerial(16, name=name, typeName='Sint16', signed=True)
return c_int16(v).value
def readUint8(self, name, decode=True, typeName='Uint8'):
......@@ -576,7 +578,7 @@ class BitStream():
return v
def readSint8(self, name):
v = self.readSerial(8, name=name, typeName='Sint8')
v = self.readSerial(8, name=name, typeName='Sint8', signed=True)
return c_int8(v).value
def readUint64(self, name):
......@@ -865,6 +867,49 @@ class BitStream():
self._read = readBefore
return ret
def extractAllData(self):
ret = ""
readBefore = self._read
self._read = 0
while self._read < self._pos:
if self._pos - self._read >= 8:
nsize = 8
else:
nsize = self._pos - self._read
data = self.readSerial(nsize, decode=False)
if nsize == 1:
ret += "{0:01b}".format(data)
elif nsize == 2:
ret += "{0:02b}".format(data)
elif nsize == 3:
ret += "{0:03b}".format(data)
elif nsize == 4:
ret += "{0:04b}".format(data)
elif nsize == 5:
ret += "{0:05b}".format(data)
elif nsize == 6:
ret += "{0:06b}".format(data)
elif nsize == 7:
ret += "{0:07b}".format(data)
else:
ret += "{0:08b}".format(data)
self._read = readBefore
ret2 = []
last = 0
for x, y, name, typeName, value in self._groupRead:
if not typeName:
nbbit = y - x
typeName = "%d bit" % nbbit
if nbbit > 1:
typeName += "s"
ret2.append("<" + str(x) + ':' + str(y-1) + "> " + '(' + typeName + ') ' + str(name) + ' => ' + str(value) + " : " + ret[x:y])
last = y
if last < self._pos:
ret2.append("<" + str(last) + ':' + str(self._pos - 1) + "> " + ret[last:])
return ret2
def checkOnlyZeroAtEnd(self):
readBefore = self._read
while self._read < self._pos:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment