## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
-from common.srdhelper import bitpack
+from common.srdhelper import bitpack_msb
import sigrokdecode as srd
class SamplerateError(Exception):
x = self.last_databit + 1
crc_bits = self.bits[x:x + self.crc_len + 1]
- bits = crc_bits
- bits.reverse()
- self.crc = bitpack(bits)
+ self.crc = bitpack_msb(crc_bits)
self.putb([11, ['%s sequence: 0x%04x' % (crc_type, self.crc),
'%s: 0x%04x' % (crc_type, self.crc), '%s' % crc_type]])
if not self.is_valid_crc(crc_bits):
# Bits 15-18: Data length code (DLC), in number of bytes (0-8).
elif bitnum == self.dlc_start + 3:
- bits = self.bits[self.dlc_start:self.dlc_start + 4]
- bits.reverse()
- self.dlc = bitpack(bits)
+ self.dlc = bitpack_msb(self.bits[self.dlc_start:self.dlc_start + 4])
self.putb([10, ['Data length code: %d' % self.dlc,
'DLC: %d' % self.dlc, 'DLC']])
self.last_databit = self.dlc_start + 3 + (dlc2len(self.dlc) * 8)
self.ss_databytebits.append(self.samplenum) # Last databyte bit.
for i in range(dlc2len(self.dlc)):
x = self.dlc_start + 4 + (8 * i)
- bits = self.bits[x:x + 8]
- bits.reverse()
- b = bitpack(bits)
+ b = bitpack_msb(self.bits[x:x + 8])
self.frame_bytes.append(b)
ss = self.ss_databytebits[i * 8]
es = self.ss_databytebits[((i + 1) * 8) - 1]
# Bits 14-31: Extended identifier (EID[17..0])
elif bitnum == 31:
- bits = self.bits[14:]
- bits.reverse()
- self.eid = bitpack(bits)
+ self.eid = bitpack_msb(self.bits[14:])
s = '%d (0x%x)' % (self.eid, self.eid)
self.putb([4, ['Extended Identifier: %s' % s,
'Extended ID: %s' % s, 'Extended ID', 'EID']])
# Bits 35-38: Data length code (DLC), in number of bytes (0-8).
elif bitnum == self.dlc_start + 3:
- bits = self.bits[self.dlc_start:self.dlc_start + 4]
- bits.reverse()
- self.dlc = bitpack(bits)
+ self.dlc = bitpack_msb(self.bits[self.dlc_start:self.dlc_start + 4])
self.putb([10, ['Data length code: %d' % self.dlc,
'DLC: %d' % self.dlc, 'DLC']])
self.last_databit = self.dlc_start + 3 + (dlc2len(self.dlc) * 8)
self.ss_databytebits.append(self.samplenum) # Last databyte bit.
for i in range(dlc2len(self.dlc)):
x = self.dlc_start + 4 + (8 * i)
- bits = self.bits[x:x + 8]
- bits.reverse()
- b = bitpack(bits)
+ b = bitpack_msb(self.bits[x:x + 8])
self.frame_bytes.append(b)
ss = self.ss_databytebits[i * 8]
es = self.ss_databytebits[((i + 1) * 8) - 1]
# Bits 1-11: Identifier (ID[10..0])
# The bits ID[10..4] must NOT be all recessive.
elif bitnum == 11:
- bits = self.bits[1:]
- bits.reverse()
# BEWARE! Don't clobber the decoder's .id field which is
# part of its boiler plate!
- self.ident = bitpack(bits)
+ self.ident = bitpack_msb(self.bits[1:])
self.fullid = self.ident
s = '%d (0x%x)' % (self.ident, self.ident),
self.putb([3, ['Identifier: %s' % s, 'ID: %s' % s, 'ID']])