UART.any() needs an argument says Thonny REPL

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
paulsk
Posts: 11
Joined: Tue Jun 01, 2021 9:54 am
Location: Lisbon
Contact:

UART.any() needs an argument says Thonny REPL

Post by paulsk » Tue Jun 01, 2021 12:00 pm

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

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

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

Post by Roberthh » Tue Jun 01, 2021 12:17 pm

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()

paulsk
Posts: 11
Joined: Tue Jun 01, 2021 9:54 am
Location: Lisbon
Contact:

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

Post by paulsk » Wed Jun 02, 2021 10:28 am

That's it! Thank you

Post Reply