core_cmd_tlm.py 文件源码

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

项目:OverviewOne 作者: SpaceVR-O1 项目源码 文件源码
def _pack_array(values, definition, fmt_string, num_bytes):
    """
    Pack an array item defined by a dictionary entry into a bytearray

    Args:
        values (tuple): 1d or 2d tuple of values to pack
        definition (dict): definition of the data item
        fmt_string (str): struct.unpack format string for an element
        num_bytes (int): number of bytes of each element

    """
    packet_part = bytearray()
    if definition['DIM_2_SIZE']:
        for dim1 in values:
            for value in dim1:
                buff = bytearray(num_bytes)
                struct.pack_into(fmt_string, buff, 0, value)
                packet_part += buff
    else:
        for value in values:
            buff = bytearray(num_bytes)
            struct.pack_into(fmt_string, buff, 0, value)
            packet_part += buff
    return packet_part
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号