Page 1 of 1

UART function

Posted: Tue Nov 12, 2019 2:11 am
by jk007
Hello, I'm afraid that I'm from China. I'm using pyb1.1. When using the official firmware version v1.93, UART (2) can use UART.readline() to read a row of data normally, but this version can't use ssd1306. When using the official firmware version v1.11, ssd1306 can be driven, but the data obtained by UART. readline() is a single letter. Where can I see the differences between versions? Thank you
------------------------------------------------------------------

Code: Select all

from pyb import DAC, Pin, ADC, UART
uart = UART(2, 9600)
while True:
    if uart.any():
        data = uart.readline()
        print(data)
------------------------------------------------------------------
##################debug from v1.11##################
MicroPython v1.11 on 2019-05-29; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>>
MPY: sync filesystems
MPY: soft reboot
b'H'
b'e'
b'l'
b'l'
b'o'
##################debug from v1.9.3 ##################
MicroPython v1.9.3 on 2017-11-01; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>>
PYB: sync filesystems
PYB: soft reboot
b'Hello'
///////////////////////////////////////////////////////
As you can see, with the same code, the output information of different firmware versions is different. V1.93 gets' hello ', while v1.11 gets' H', 'e', 'l', 'l', 'o'

Re: UART function

Posted: Tue Nov 12, 2019 2:35 am
by jimmo
Hi,

I think the change was that earlier this year (commit 34942d0a72980173eca51b201f271f67bcae46b5) the default timeout for the UART on STM32 was changed from 1000ms to 0ms (i.e. non-blocking).

So to get the old behavior back, use

Code: Select all

uart = UART(2, 9600, timeout=1000)

Re: UART function

Posted: Thu Nov 14, 2019 6:10 am
by jk007
OK, thank you. I'll try