15 Star 38 Fork 10

Neeil/DreamSerial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Utils.py 820 Bytes
一键复制 编辑 原始数据 按行查看 历史
Neil Wang 提交于 2016-03-03 16:01 +08:00 . Added config.json to store last usage config.
# -*- coding: utf-8 -*-
__author__ = 'fg086897'
def HexString2ByteArray(hexString):
byteStrArray = [int(x, 16) for x in hexString.replace('0x', '').split()]
return byteStrArray
def checkData(data, _type):
if "" == data:
return False, u"Data can't be NULL"
errch, msg = None, 'Success'
if 'hex' == _type:
data = ''.join(data.split())
if 0 != len(data) / 2:
errch, msg = True, 'Data Length Error'
else:
for ch in data.upper():
if not ('0' <= ch <= '9' or 'A' <= ch <= 'F'):
errch, msg = ch, 'Error Hex Char'
break;
return not errch, msg
def getByteArray(data, _type):
if 'hex' == _type:
return HexString2ByteArray(data)
else:
return bytes(data, 'utf-8')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Neeil/DreamSerial.git
git@gitee.com:Neeil/DreamSerial.git
Neeil
DreamSerial
DreamSerial
master

搜索帮助