Adjusting timeout of UART after creating the object?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
liudr
Posts: 211
Joined: Tue Oct 17, 2017 5:18 am

Adjusting timeout of UART after creating the object?

Post by liudr » Fri Dec 24, 2021 11:50 pm

I wish to adjust the timeout of an UART port I instantiated. I can't find anything in the reference:

https://docs.micropython.org/en/latest/ ... .UART.html

I can't just assign value to UART.timeout. That is not a member variable. So is there any way to make changes to the timeout? Thanks.

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Adjusting timeout of UART after creating the object?

Post by marcidy » Sun Dec 26, 2021 12:37 am

Why do you need to do this / what is the requirement? any reason you can't just re-init it?

User avatar
liudr
Posts: 211
Joined: Tue Oct 17, 2017 5:18 am

Re: Adjusting timeout of UART after creating the object?

Post by liudr » Sun Dec 26, 2021 6:12 pm

Thanks. I could just call machine.UART() again? There's no indication it would work or what would happen if it gets called again.
So I did some experimentation with calling it and sending and receiving data and with gc.
It seems to work fine as long as I call gc.collect() to release memory from the previous callse to machine.UART().

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: Adjusting timeout of UART after creating the object?

Post by davef » Sun Dec 26, 2021 6:52 pm

Your last comment:
It seems to work fine as long as I call gc.collect() to release memory from the previous callse to machine.UART().
Do you have to do this just with machine.UART() or is calling gc.collect() required before making a new call to other methods?

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Adjusting timeout of UART after creating the object?

Post by marcidy » Sun Dec 26, 2021 10:02 pm

You can call uart.deinit() just before recreating it as well

Post Reply