Example #1
0
 def check_line(self, line, format_type):
     if format_type == DATA:
         if line.length != len(line.chunk):
             raise hexfile.InvalidRecordLengthError("Byte count doesn't match length of actual data.")
         checksum = checksums.lrc(utils.make_list(utils.int_to_array(line.address), line.length, line.chunk), 16, checksums.COMPLEMENT_NONE)
         if line.checksum != checksum:
             raise hexfile.InvalidRecordChecksumError()
Example #2
0
 def composeRow(self, address, length, row):
     checksum = checksums.lrc(
         utils.makeList(utils.intToArray(address), length, row), 16,
         checksums.COMPLEMENT_NONE)
     line = ";{0:02X}{1:04X}{2!s}{3:04X}".format(length, address,
                                                 Writer.hexBytes(row),
                                                 checksum)
     return line
Example #3
0
 def checkLine(self, line, formatType):
     if line.length != len(line.chunk):
         raise hexfile.InvalidRecordLengthError(
             "Byte count doesn't match length of actual data.")
     checksum = checksums.lrc(
         utils.makeList(line.type, line.length,
                        utils.intToArray(line.address), line.chunk), 8,
         checksums.COMPLEMENT_TWOS)
     if line.checksum != checksum:
         raise hexfile.InvalidRecordChecksumError()
Example #4
0
 def compose_row(self, address, length, row):
     tmp = 0  # TODO: format type!?
     checksum = checksums.lrc(
         utils.make_list(tmp, length + 4, utils.int_to_array(address), row),
         8, checksums.COMPLEMENT_TWOS)
     if length < self.row_length:
         lengthToPad = self.row_length - length
         padding = [0] * (lengthToPad)
         row.extend(padding)
     line = "{0:02X}{1}0000{2:08X}{3}".format(checksum, length - 2, address,
                                              Writer.hex_bytes(row))
     return line
Example #5
0
 def check_line(self, line, format_type):
     if format_type == EOF:
         return True
     line.length -= 4
     if line.length != len(line.chunk):
         line.chunk = line.chunk[:line.length]  # Cut padding.
     if format_type == DATA_ABS:
         tmp = 0
         self.last_address = line.address + line.length
     elif format_type == DATA_INC:
         tmp = 1
         line.address = self.last_address
     elif format_type == DATA_REL:
         self.error("relative adressing not supported.")
         tmp = 2
     else:
         self.error("Invalid format type: '{0}'".format(format_type))
         tmp = 0
     checksum = checksums.lrc(
         utils.make_list(tmp, line.length + 4,
                         utils.int_to_array(line.address), line.chunk), 8,
         checksums.COMPLEMENT_TWOS)
     if line.checksum != checksum:
         raise hexfile.InvalidRecordChecksumError()
Example #6
0
 def testLRCCase5(self):
     self.assertEqual(lrc(range(10), 8, COMPLEMENT_TWOS), 211)
Example #7
0
 def testLRCCase6(self):
     self.assertEqual(lrc(range(100), 8, COMPLEMENT_TWOS), 170)
Example #8
0
def testLRCCase9():
    assert lrc(range(10), 16, COMPLEMENT_ONES) == 65490
Example #9
0
 def testLRCCase4(self):
     self.assertEqual(lrc(range(100), 8, COMPLEMENT_ONES), 169)
Example #10
0
def testLRCCase11():
    assert lrc(range(10), 16, COMPLEMENT_TWOS) == 65491
Example #11
0
 def testLRCCase17(self):
     self.assertEqual(lrc(range(10), 32, COMPLEMENT_TWOS), 4294967251)
Example #12
0
def testLRCCase18():
    assert lrc(range(100), 32, COMPLEMENT_TWOS) == 4294962346
Example #13
0
 def testLRCCase10(self):
     self.assertEqual(lrc(range(100), 16, COMPLEMENT_ONES), 60585)
Example #14
0
def testLRCCase16():
    assert lrc(range(100), 32, COMPLEMENT_ONES) == 4294962345
Example #15
0
def testLRCCase17():
    assert lrc(range(10), 32, COMPLEMENT_TWOS) == 4294967251
Example #16
0
def testLRCCase15():
    assert lrc(range(10), 32, COMPLEMENT_ONES) == 4294967250
Example #17
0
def testLRCCase14():
    assert lrc(range(100), 32, COMPLEMENT_NONE) == 4950
Example #18
0
def testLRCCase12():
    assert lrc(range(100), 16, COMPLEMENT_TWOS) == 60586
Example #19
0
 def testLRCCase7(self):
     self.assertEqual(lrc(range(10), 16, COMPLEMENT_NONE), 45)
Example #20
0
 def testLRCCase12(self):
     self.assertEqual(lrc(range(100), 16, COMPLEMENT_TWOS), 60586)
Example #21
0
 def testLRCCase9(self):
     self.assertEqual(lrc(range(10), 16, COMPLEMENT_ONES), 65490)
Example #22
0
 def testLRCCase15(self):
     self.assertEqual(lrc(range(10), 32, COMPLEMENT_ONES), 4294967250)
Example #23
0
 def testLRCCase11(self):
     self.assertEqual(lrc(range(10), 16, COMPLEMENT_TWOS), 65491)
Example #24
0
def testLRCCase10():
    assert lrc(range(100), 16, COMPLEMENT_ONES) == 60585
Example #25
0
 def testLRCCase14(self):
     self.assertEqual(lrc(range(100), 32, COMPLEMENT_NONE), 4950)
Example #26
0
def testLRCCase6():
    assert lrc(range(100), 8, COMPLEMENT_TWOS) == 170
Example #27
0
 def testLRCCase16(self):
     self.assertEqual(lrc(range(100), 32, COMPLEMENT_ONES), 4294962345)
Example #28
0
 def testLRCCase2(self):
     self.assertEqual(lrc(range(100), 8, COMPLEMENT_NONE), 86)
Example #29
0
 def testLRCCase18(self):
     self.assertEqual(lrc(range(100), 32, COMPLEMENT_TWOS), 4294962346)
Example #30
0
def testLRCCase8():
    assert lrc(range(100), 16, COMPLEMENT_NONE) == 4950