1 Star 0 Fork 10

jasper / DreamSerial

forked from Neeil / DreamSerial 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
TinaUtils.py 790 Bytes
一键复制 编辑 原始数据 按行查看 历史
# -*- coding: utf-8 -*-
__author__ = 'fg086897'
import logging
from ccitt_crc import ccitt_crc
import binascii
logger = logging.getLogger('main.TinaUtils')
class TinaUtils():
def __init__(self):
logger.info('TinaUtils Init')
def generateReadRegsCommand(self,startAddress, length):
addressL = startAddress & 0xFF
addressH = (startAddress >> 8 ) & 0xFF
lengthL = length & 0xFF
lengthH= (length >> 8 ) & 0xFF
tinaCmd = [0xAA, 0x01, addressL, addressH, lengthL, lengthH]
ccittCrc = ccitt_crc()
crc = ccittCrc.ccitt_crc_calc(tinaCmd[1:])
tinaCmd.append(crc & 0xFF)
tinaCmd.append((crc >> 8) & 0xFF)
# tinaHex = [hex(x) for x in tinaCmd]
# logger.info(tinaHex)
return tinaCmd
1
https://gitee.com/lscherry/DreamSerial.git
git@gitee.com:lscherry/DreamSerial.git
lscherry
DreamSerial
DreamSerial
master

搜索帮助