本文整理汇总了Python中TestLib.toHex方法的典型用法代码示例。如果您正苦于以下问题:Python TestLib.toHex方法的具体用法?Python TestLib.toHex怎么用?Python TestLib.toHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestLib
的用法示例。
在下文中一共展示了TestLib.toHex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: zeroes
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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: onesZeroes
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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: getSerial
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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
示例4: qieDaisyChain0
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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: qieDaisyChain0
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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
示例6: getUniqueIDs
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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
示例7: bridgeTests
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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 '\[email protected]@@@@@ 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
示例8: checkCRC
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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'
示例9: simplePrint
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
def simplePrint(message):
hex_message = t.toHex(message,1)
print 'int message: ', message
print 'hex message:', hex_message
return hex_message
示例10: fwVersion
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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
示例11: simplePrint
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
def simplePrint(message):
hex_message = t.toHex(message,1)
print 'int message: '+str(message)
print 'hex message:'+str(hex_message)
return hex_message
示例12: simplePrint
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
def simplePrint(message):
hex_message = t.toHex(message,1)
return hex_message
示例13: qieDaisyChain1
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
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
示例14: onesZeroes
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
def onesZeroes(message):
correct_value = '0xaaaaaaaa'
hex_message = t.toHex(message,0)
return passFail(hex_message==correct_value)
示例15: zeroes
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import toHex [as 别名]
def zeroes(message):
correct_value = '0x00000000'
hex_message = t.toHex(message,0)
return passFail(hex_message==correct_value)