Definitions for internal functions

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Definitions for internal functions

Post by lnsri22 » Sat Jan 26, 2019 6:25 am

Hello Everyone!!

Where can I find the definitions for internal class functions (eg : uart.readinto) in the repo??



Thanks in advance!!
lnsri22 :)

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Definitions for internal functions

Post by stijn » Sat Jan 26, 2019 9:09 am

Search for places in *.c files where 'readinto' gets registered in a locals_dict , and look for the matching file for the port you are interested in (it's possible not all ports use the exact same implementation so this matters). You'll find matches like

Code: Select all

micropython/ports/esp32/machine_uart.c:
  334:     { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
Now go to the definition of mp_stream_readinto_obj in micropython/py/stream.c to see what function that is mapped to, it's stream_readinto. Which in turn calls mp_stream_read_exactly, which in trun calls mp_stream_rw and so on, which eventually leads back into machine_uart.c to call the actual harware I/O functionality.

lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

Re: Definitions for internal functions

Post by lnsri22 » Sat Jan 26, 2019 9:36 am

Thanks for the reference :)

I will give it a try and let you know

Cheers!!
lnsri22 :)

Post Reply