decode.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:fdxread 作者: lkarsten 项目源码 文件源码
def checklength(pdu, speclen):
    "pdu is hex encoded, 4 bits per char."
    assert type(pdu) == str
    assert speclen is None or isinstance(speclen, int)

    assert len(pdu) % 2 == 0

    if speclen is not None:
        if len(pdu)/2 != speclen:
            raise DataError("mtype=0x%s: Incorrect length %s (got %s) body: %s"
                            % (pdu[:3*2], speclen, len(pdu)/2, pdu[3*2:]))
    return BitArray(hex=pdu[3*2:-1*2])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号