代码拉取完成,页面将自动刷新
同步操作将从 Neeil/DreamSerial 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 11:33:15 2015
@author: fg086897
"""
__author__ = 'Neil Wang'
import ccitt_crc
class DsPackage(object):
access = 'reg'
def __init__(self, rw, access, address, length):
self.rw = rw
self.access = access
self.address = address
self.length = length
def generatePackage(self):
package = [0 for n in range(8)]
package[0] = 0xAA
if self.rw.lower() == 'r' :
package[1] &= 0x3F
elif self.rw.lower() == 'w':
package[1] |= 0x80
package.append([0 for n in range(self.length)])
else :
print('Please input access as "r" or "w"')
pass
if self.access == 'reg':
package[1] += 0x01
elif self.access == 'data':
package[1] += 0x03
else :
print('Please input access as "reg" or "data"')
pass
package[2] = self.address & 0xff
package[3] = (self.address >> 8) & 0xff
package[4] = self.length & 0xff
package[5] = (self.length >> 8 ) & 0xff
crc = ccitt_crc.ccitt_crc();
crcValue = crc.ccitt_crc_calc(package[1:-2])
package[-1] = (crcValue >> 8 ) & 0xff
package[-2] = crcValue & 0xff
return package
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。