UART function

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
jk007
Posts: 9
Joined: Tue Nov 12, 2019 1:34 am

UART function

Post by jk007 » Tue Nov 12, 2019 2:11 am

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'

User avatar
jimmo
Posts: 1938
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: UART function

Post by jimmo » Tue Nov 12, 2019 2:35 am

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)

jk007
Posts: 9
Joined: Tue Nov 12, 2019 1:34 am

Re: UART function

Post by jk007 » Thu Nov 14, 2019 6:10 am

OK, thank you. I'll try

Post Reply