Skip to content

从下位机读取数据后是如何进行处理的? #3

Description

@SparkingLight1

(1)
read = ser.read(3)
read = bytearray(read)
无论是编码器,LED,还是蜂鸣器可以向控制器发送数据,控制器可以通过串口ser.read(3)读取,请问读取的数据是什么数据类型?bytearry(read)后编程字符串数组后,数组元素是什么数据类型?
(2)
pack = struct.pack('h',pwm)
data = bytearray([0x03, pack[0], pack[1]])
给下位机发送数据的时候,为什么使用struct方法?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions