예제 #1
0
def zeroes(message):
    correct_value = '0x00000000'
    hex_message = t.toHex(message,0)
    print 'correct value: ', correct_value
    print 'int message: ', message
    print 'hex message: ', hex_message
    return passFail(hex_message==correct_value)
예제 #2
0
def onesZeroes(message):
    correct_value = '0xaaaaaaaa'
    hex_message = t.toHex(message, 0)
    print 'correct value: ' + str(correct_value)
    print 'int message: ' + str(message)
    print 'hex message: ' + str(hex_message)
    return passFail(hex_message == correct_value)
예제 #3
0
def onesZeroes(message):
    correct_value = '0xaaaaaaaa'
    hex_message = t.toHex(message,0)
    print 'correct value: '+str(correct_value)
    print 'int message: '+str(message)
    print 'hex message: '+str(hex_message)
    return passFail(hex_message==correct_value)
예제 #4
0
def qieDaisyChain0(message):
    hex_message = t.toHex(message,1)
    print 'int message: '+str(message)
    print 'hex message:'+str(hex_message)
    split_message = t.splitMessage(hex_message,6)
    for i in xrange(len(split_message)):
        print 'QIE '+str(i+1)+': '+str(split_message[i])
    return hex_message
예제 #5
0
 def getSerial(self):
     if int(self.raw.split()[1]) != 0x70:
         print 'Not in Family 0x70'
         return 'Family_Code_Error'
     serial = t.serialNum(self.raw)  # cereal
     oats = t.reverse(serial)  # reversed
     eggs = t.toHex(oats)  # hex
     return eggs
예제 #6
0
def qieDaisyChain0(message):
    hex_message = t.toHex(message,1)
    print 'int message: ', message
    print 'hex message:', hex_message
    split_message = t.splitMessage(hex_message,6)
    for i in xrange(len(split_message)):
        print 'QIE ',i+1,': ',split_message[i]
    return hex_message
예제 #7
0
 def getSerial(self):
     if int(self.raw.split()[1]) != 0x70:
         print 'Not in Family 0x70'
         return 'Family_Code_Error'
     serial = t.serialNum(self.raw) # cereal
     oats = t.reverse(serial) # reversed
     eggs = t.toHex(oats) # hex
     return eggs
예제 #8
0
def qieDaisyChain0(message):
    hex_message = t.toHex(message, 1)
    print 'int message: ' + str(message)
    print 'hex message:' + str(hex_message)
    split_message = t.splitMessage(hex_message, 6)
    for i in xrange(len(split_message)):
        print 'QIE ' + str(i + 1) + ': ' + str(split_message[i])
    return hex_message
예제 #9
0
def getUniqueIDs(rmList, slotList, verbose=0):
    print "Unique IDs"
    uniqueIDArray = []
    # Iterate through RM 0, 1, 2, 3 (include desired RMs in list)
    for rm in rmList:
        print '--- RM ',rm, ' ---'
        t.openRM(rm)
        idList = []
        # Iterate through Slot 0, 1, 2, 3 (run for all 4 slots by default)
        for slot in slotList[rm]:
            message = uniqueID(slot)
            # print checkCRC(message,7,10, verbose)
            final_message = t.serialNum(message)
            final_message = t.reverse(final_message)
            final_message = t.toHex(final_message)
            idList.append(message)
            print 'Slot ',slot,': ',message,'\t-> ',final_message
        uniqueIDArray.append(idList)
    return uniqueIDArray
예제 #10
0
def getUniqueIDs(rmList, slotList, verbose=0):
    print "Unique IDs"
    uniqueIDArray = []
    # Iterate through RM 0, 1, 2, 3 (include desired RMs in list)
    for rm in rmList:
        print '--- RM ', rm, ' ---'
        t.openRM(rm)
        idList = []
        # Iterate through Slot 0, 1, 2, 3 (run for all 4 slots by default)
        for slot in slotList[rm]:
            message = uniqueID(slot)
            # print checkCRC(message,7,10, verbose)
            final_message = t.serialNum(message)
            final_message = t.reverse(final_message)
            final_message = t.toHex(final_message)
            idList.append(message)
            print 'Slot ', slot, ': ', message, '\t-> ', final_message
        uniqueIDArray.append(idList)
    return uniqueIDArray
예제 #11
0
def bridgeTests(slot, testList, verbosity=0):
    passed = 0
    failed = 0
    neither = 0
    num_tests = len(testList)
    print '## Number of Tests: ', num_tests
    for test in testList:
        print '\nNumber: ', test, ' ###'
        print 'Name: ', bridgeDict[test]['name']
        function = bridgeDict[test]['function']
        address = bridgeDict[test]['address']
        num_bytes = bridgeDict[test]['bits']/8
        message = readBridge(slot, address, num_bytes)
        # print '*** RAW MESSAGE :', t.reverseBytes(message)
        print 'hex message: ', t.toHex(message,1)

        # Check for i2c Error
        mList = message.split()
        error = mList.pop(0)
        if int(error) != 0:
            print '\n@@@@@@ I2C ERROR : ',message,'\n'
        message = " ".join(mList)

        result = function(message)
        print 'RESULT = ',result
        if result == 'PASS':
            passed += 1
        elif result == 'FAIL':
            failed += 1
        else:
            print 'Neither PASS Nor FAIL'
            neither += 1
        if verbosity:
            print 'Register Name: ', bridgeDict[test]['name']
            print 'Register Value: ', message
            print 'Test Result: ', result

    test_list = [passed, failed, neither]
    return test_list
예제 #12
0
def bridgeTests(slot, testList, verbosity=0):
    passed = 0
    failed = 0
    neither = 0
    num_tests = len(testList)
    print '## Number of Tests: ', num_tests
    for test in testList:
        print '\nNumber: ', test, ' ###'
        print 'Name: ', bridgeDict[test]['name']
        function = bridgeDict[test]['function']
        address = bridgeDict[test]['address']
        num_bytes = bridgeDict[test]['bits'] / 8
        message = readBridge(slot, address, num_bytes)
        # print '*** RAW MESSAGE :', t.reverseBytes(message)
        print 'hex message: ', t.toHex(message, 1)

        # Check for i2c Error
        mList = message.split()
        error = mList.pop(0)
        if int(error) != 0:
            print '\n@@@@@@ I2C ERROR : ', message, '\n'
        message = " ".join(mList)

        result = function(message)
        print 'RESULT = ', result
        if result == 'PASS':
            passed += 1
        elif result == 'FAIL':
            failed += 1
        else:
            print 'Neither PASS Nor FAIL'
            neither += 1
        if verbosity:
            print 'Register Name: ', bridgeDict[test]['name']
            print 'Register Value: ', message
            print 'Test Result: ', result

    test_list = [passed, failed, neither]
    return test_list
예제 #13
0
def checkCRC(message, numBytes, base=10, verbose=0):
    POLYNOMIAL = 0x131 # x^8 + x^5 + x^4 + 1 -> 9'b100110001 = 0x131
    crc = 0
    mList = toIntList(message, base)
    errorCode = mList[0]
    dataList = mList[1:-1]
    checksum = mList[-1]
    if verbose > 2:
        print 'hex = ',t.toHex(message)
        print 'data = ',dataList
        print 'checksum = ',checksum
    if errorCode != 0:
        return 'I2C_BUS_ERROR'
    # calculates 8-bit checksum with give polynomial
    for byteCtr in xrange(numBytes):
        crc ^= dataList[byteCtr]
        # crc &= 0xFF
        if verbose > 1:
            print "CRC = ",crc
        for bit in xrange(8,0,-1):
            if crc & 0x80: # True if crc >= 128, False if crc < 128
                crc = (crc << 1) ^ POLYNOMIAL
                # crc &= 0xFF
                if verbose > 1:
                    print 'true crc = ',crc
            else: # crc < 128
                crc = (crc << 1)
                # crc &= 0xFF
                if verbose > 1:
                    print 'false crc = ',crc
    if verbose > 0:
        print 'CRC = ',crc
        print 'checksum = ',checksum
    if crc != checksum:
        return 'CHECKSUM_ERROR'
    return 'CHECKSUM_OK'
예제 #14
0
def checkCRC(message, numBytes, base=10, verbose=0):
    POLYNOMIAL = 0x131  # x^8 + x^5 + x^4 + 1 -> 9'b100110001 = 0x131
    crc = 0
    mList = toIntList(message, base)
    errorCode = mList[0]
    dataList = mList[1:-1]
    checksum = mList[-1]
    if verbose > 2:
        print 'hex = ', t.toHex(message)
        print 'data = ', dataList
        print 'checksum = ', checksum
    if errorCode != 0:
        return 'I2C_BUS_ERROR'
    # calculates 8-bit checksum with give polynomial
    for byteCtr in xrange(numBytes):
        crc ^= dataList[byteCtr]
        # crc &= 0xFF
        if verbose > 1:
            print "CRC = ", crc
        for bit in xrange(8, 0, -1):
            if crc & 0x80:  # True if crc >= 128, False if crc < 128
                crc = (crc << 1) ^ POLYNOMIAL
                # crc &= 0xFF
                if verbose > 1:
                    print 'true crc = ', crc
            else:  # crc < 128
                crc = (crc << 1)
                # crc &= 0xFF
                if verbose > 1:
                    print 'false crc = ', crc
    if verbose > 0:
        print 'CRC = ', crc
        print 'checksum = ', checksum
    if crc != checksum:
        return 'CHECKSUM_ERROR'
    return 'CHECKSUM_OK'
예제 #15
0
def simplePrint(message):
    hex_message = t.toHex(message, 1)
    print 'int message: ' + str(message)
    print 'hex message:' + str(hex_message)
    return hex_message
예제 #16
0
def fwVersion(message):
    # correct_value = "N/A" # We need to find Firmware Version
    message = t.toHex(message)
    return message
예제 #17
0
def fwVersion(message):
    # correct_value = "N/A" # We need to find Firmware Version
    message = t.toHex(message)
    # print 'correct value: '+str(correct_value)
    print 'hex message: '+str(message)
    return message
예제 #18
0
def fwVersion(message):
    # correct_value = "N/A" # We need to find Firmware Version
    message = t.toHex(message)
    return message
예제 #19
0
def zeroes(message):
    correct_value = '0x00000000'
    hex_message = t.toHex(message,0)
    return passFail(hex_message==correct_value)
예제 #20
0
def simplePrint(message):
    hex_message = t.toHex(message,1)
    print 'int message: '+str(message)
    print 'hex message:'+str(hex_message)
    return hex_message
예제 #21
0
def onesZeroes(message):
    correct_value = '0xaaaaaaaa'
    hex_message = t.toHex(message,0)
    return passFail(hex_message==correct_value)
예제 #22
0
def qieDaisyChain1(message):
    hex_message = t.toHex(message,1)
    split_message = t.splitMessage(hex_message,6)
    for i in xrange(len(split_message)):
        print 'QIE ',i+7,': ',split_message[i]
    return hex_message
예제 #23
0
def simplePrint(message):
    hex_message = t.toHex(message, 1)
    return hex_message
예제 #24
0
def qieDaisyChain1(message):
    hex_message = t.toHex(message, 1)
    split_message = t.splitMessage(hex_message, 6)
    for i in xrange(len(split_message)):
        print 'QIE ', i + 7, ': ', split_message[i]
    return hex_message
예제 #25
0
def simplePrint(message):
    hex_message = t.toHex(message,1)
    return hex_message
예제 #26
0
def zeroes(message):
    correct_value = '0x00000000'
    hex_message = t.toHex(message, 0)
    return passFail(hex_message == correct_value)
예제 #27
0
def onesZeroes(message):
    correct_value = '0xaaaaaaaa'
    hex_message = t.toHex(message, 0)
    return passFail(hex_message == correct_value)
예제 #28
0
def simplePrint(message):
    hex_message = t.toHex(message,1)
    print 'int message: ', message
    print 'hex message:', hex_message
    return hex_message
예제 #29
0
def fwVersion(message):
    # correct_value = "N/A" # We need to find Firmware Version
    message = t.toHex(message)
    # print 'correct value: '+str(correct_value)
    print 'hex message: ' + str(message)
    return message