0

我正在尝试从 MicroPython 中的 uart 端口接收数据。我正在使用风速计,每秒发送一次风读数。我需要每秒读取该数据。我创建了一个while循环来读取数据,但是它被命中和错过了。当没有任何数据时,UART返回“无”。例如,我需要在 10 秒内获得 10 个风速读数。

 if start_reading:
    t0 = 0
    while t0 < 1:
        t0 = t0 + .1
        print(t0)
        #print(time.time() - t0)
        data = ser_gauge.readline()
        #print(data)
        if ser_gauge.any() != 'none':
            command = data
4

0 回答 0