C module programming reference

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
bitrat
Posts: 20
Joined: Fri Jul 26, 2019 4:13 am

Re: C module programming reference

Post by bitrat » Mon Sep 02, 2019 9:59 pm

I forgot to mention yesterday that in my reference, each module is a minimal C example that you can start to hack right away.
@Zoltán


Absolutely! Your examples are great! :-)

bitrat
Posts: 20
Joined: Fri Jul 26, 2019 4:13 am

Re: C module programming reference

Post by bitrat » Mon Sep 02, 2019 10:02 pm

Thanks!

User avatar
pythoncoder
Posts: 4471
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: C module programming reference

Post by pythoncoder » Tue Sep 03, 2019 9:12 am

@v923z That's a great piece of work, an excellent explanation with really good code examples. :D

Just one comment. The Jupyter/IPython/Sphinx content at the start is quite daunting. The information on generating the documentation, while useful, isn't needed for those reading the doc online. Would those early sections be better at the end? For people unfamiliar with the tools you employ your doc is great, so long as they start reading somewhere around "The micropython code base".

As a matter of interest have you seen these C stub generators? https://github.com/pazzarpj/micropython-ustubby and https://gitlab.com/oliver.robson/mpy-c-stub-gen.
Peter Hinch

v923z
Posts: 153
Joined: Mon Dec 28, 2015 6:19 pm

Re: C module programming reference

Post by v923z » Tue Sep 03, 2019 5:50 pm

Greetings Peter,
pythoncoder wrote:
Tue Sep 03, 2019 9:12 am
@v923z That's a great piece of work, an excellent explanation with really good code examples. :D

Just one comment. The Jupyter/IPython/Sphinx content at the start is quite daunting. The information on generating the documentation, while useful, isn't needed for those reading the doc online. Would those early sections be better at the end? For people unfamiliar with the tools you employ your doc is great, so long as they start reading somewhere around "The micropython code base".
This is a fair point. I can drop the whole jupyter section, if you think it is distracting. In fact, all I have to do is exclude the source file in index.rst.
pythoncoder wrote:
Tue Sep 03, 2019 9:12 am

As a matter of interest have you seen these C stub generators? https://github.com/pazzarpj/micropython-ustubby and https://gitlab.com/oliver.robson/mpy-c-stub-gen.
No, I haven't seen that. Thanks for the pointer! I think I should mention these somewhere in the documentation.

Best,

Zoltán

User avatar
pythoncoder
Posts: 4471
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: C module programming reference

Post by pythoncoder » Wed Sep 04, 2019 5:59 am

Hi Zoltán,

perhaps the Jupyter/IPython/Sphinx content warrants a separate doc, with some advocacy explaining exactly what they offer the MicroPython developer. While I have some familiarity with Sphinx I'm new to the other two. From a quick read IPython seems to offer a lot to CPython devs, but I couldn't see its relevance to MicroPython. But that may just be me failing to get the point...
Peter Hinch

v923z
Posts: 153
Joined: Mon Dec 28, 2015 6:19 pm

Re: C module programming reference

Post by v923z » Wed Sep 04, 2019 6:29 pm

@pythoncode

Peter, I have modified the source of the documentation as you suggested. I hope it is more readable now. I agree, the jupyter stuff was misleading.
pythoncoder wrote:
Wed Sep 04, 2019 5:59 am
perhaps the Jupyter/IPython/Sphinx content warrants a separate doc, with some advocacy explaining exactly what they offer the MicroPython developer. While I have some familiarity with Sphinx I'm new to the other two. From a quick read IPython seems to offer a lot to CPython devs, but I couldn't see its relevance to MicroPython. But that may just be me failing to get the point...
Jupyter/ipython is vast now, having support for at least 40 different languages. But that is off the point. I elected to use that, because I wanted to have a single document, and one, where I can also compile, list files, etc. I you install their extensions, then you can have really nifty stuff in the browser. E.g., automatic table of contents, spell checking, code execution time measurement (very relevant in this particular case ;) ), and a number of other things.

As for micropython: there are actually some kernels out that that you can initialise in jupyter, e.g., https://github.com/goatchurchprime/jupy ... hon_kernel, but to be honest, I don't find too much use for them. I usually go the other way: I load a proper python kernel running on the computer, and then pass code to micropython via the serial interface. You can then capture data from the board, and analyse that with all the tools available for CPython. You can find an example of that here: https://github.com/v923z/micropython/bl ... bone.ipynb .

Best,

Zoltán

v923z
Posts: 153
Joined: Mon Dec 28, 2015 6:19 pm

Re: C module programming reference

Post by v923z » Thu Sep 05, 2019 7:07 pm

Hi all,

I hope this is not getting overwhelming, but I have added a short section on how to work with string, and bumped the documentation version to 1.3. https://micropython-usermod.readthedocs ... index.html

Cheers,
Zoltán

User avatar
tuupola
Posts: 54
Joined: Sun Sep 17, 2017 12:10 am
Contact:

Re: C module programming reference

Post by tuupola » Sat Sep 07, 2019 8:43 am

This is excellent work. Thank you!

User avatar
jimmo
Posts: 1837
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: C module programming reference

Post by jimmo » Sun Sep 08, 2019 5:08 am

v923z wrote:
Thu Sep 05, 2019 7:07 pm
Hi all,

I hope this is not getting overwhelming, but I have added a short section on how to work with string, and bumped the documentation version to 1.3. https://micropython-usermod.readthedocs ... index.html

Cheers,
Zoltán
Hi!

Thanks so much for this documentation, it's really great work. I'm especially glad because I had planned to start writing the same thing and ...well.. now I don't have to :)

I'd love to see this get merged into the main MicroPython documentation, especially the internals part, but I think everything is of interest. Would you be interested in doing this? How can I help?

Thanks again!

v923z
Posts: 153
Joined: Mon Dec 28, 2015 6:19 pm

Re: C module programming reference

Post by v923z » Sun Sep 08, 2019 11:35 am

Hi Jim,
jimmo wrote:
Sun Sep 08, 2019 5:08 am

I'd love to see this get merged into the main MicroPython documentation, especially the internals part, but I think everything is of interest. Would you be interested in doing this? How can I help?
I think, merging into the main micropython documentation would mean at least two things:

1. the text should probably be a bit more formal. Not a problem.

2. I would lose "ownership" (I would have to add my own changes via pull requests). I can reconcile myself with this fact.

So, in principle, I am not against the idea, and would be happy to implement the required changes. Just let me know how we should move forward.

By the way, I have just added a licence file to the repository. Everything is under MIT licence.

Best,
Zoltán

Post Reply