Page 1 of 1

Definitions for internal functions

Posted: Sat Jan 26, 2019 6:25 am
by lnsri22
Hello Everyone!!

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



Thanks in advance!!

Re: Definitions for internal functions

Posted: Sat Jan 26, 2019 9:09 am
by stijn
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.

Re: Definitions for internal functions

Posted: Sat Jan 26, 2019 9:36 am
by lnsri22
Thanks for the reference :)

I will give it a try and let you know

Cheers!!