Page 1 of 1

UART.any() needs an argument says Thonny REPL

Posted: Tue Jun 01, 2021 12:00 pm
by paulsk
Hi, I just joined this forum.
I am experimenting with a RPi Pico.
Using Thonny IDE v 3.3.3 in MS Windows 10.
The Pico has Micropython v1.15 of 2021-04-18 installed.

I am working on a script that has to receive ansynchronus UDP messages (GPS flightsim data).
It actually is a port from a same project I did successfully in the past with a RPi Pi and later with an Arduino MEGA 2560.

In Thonny, when using the REPL mode, after entering "from machine import UART", then: dir(UART) among other things there was listed: 'any'.
According to https://docs.micropython.org/en/latest/ ... uart%20any the function any() has to be called without parameter(s), however the call 'UART.any()' in Thonny's REPL returned:

>>> UART.any()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function takes 1 positional arguments but 0 were given

After seeing this error i tried: 'UART.any(0)' and 'UART.any('0')'. Both commands resulted in errors too.
Anyone has an idea what can cause this?
Greetings,
paulsk

Re: UART.any() needs an argument says Thonny REPL

Posted: Tue Jun 01, 2021 12:17 pm
by Roberthh
You have to call uart.any() on the UART instance you have created, not the class. So you would have something like:

from machine import UART
uart=UART(1)
uart.any()

Re: UART.any() needs an argument says Thonny REPL

Posted: Wed Jun 02, 2021 10:28 am
by paulsk
That's it! Thank you