how to add a module in the lib

108 views
Skip to first unread message

Davide Carboni

unread,
Jun 29, 2010, 11:48:15 AM6/29/10
to python-on-a-chip
Hi all,
I'm trying to add a module in the lib simply putting a foo.py file in
the folder src/lib but when I clean/make ll and try to import foo in
the ipm it fails. I dove into the doc but found nothing. I see a
module.c module.h are responsible for the error but I wonder what I'm
missing.

D.

Davide Carboni

unread,
Jun 29, 2010, 11:59:21 AM6/29/10
to python-on-a-chip
Ok, I'll answer myself hoping before someone else wastes time with me.
The list of standard lib modules can be manually updated in the src/vm/
Makefile under PMSTDLIB_SOURCES. I wonder if editing the Makefile is
the right way, but in any case it works.

ziglionz

unread,
Jun 29, 2010, 5:51:33 PM6/29/10
to python-on-a-chip
I think you can add any modules to the user library without having to
change the makefile, just add them to main.py.
Otherwise you can add them in the Makefile for your platform as
PM_USR_SOURCES

E.

Dean Hall

unread,
Jul 3, 2010, 9:48:11 AM7/3/10
to python-o...@googlegroups.com
Sorry about the lack of docs about this matter.

The design is to have two places for .py libraries: src/lib/ is for
system libraries applicable to all platforms, and src/platform/
<yourplatform>/ is for platform-specific libraries. You put the .py
file in the desired directory, then modify the Makefile to process
your file at build time.

!!Dean

> --
> You are subscribed to the "python-on-a-chip" (or p14p for short)
> Google Group.
> Site: http://groups.google.com/group/python-on-a-chip

jani basha

unread,
Jun 19, 2014, 1:07:41 AM6/19/14
to python-o...@googlegroups.com
Hi
I am working on the same but on PIC32 platform and i have take v10 version of p14p.

Its compiled and working fine but when i try to add some small script(~2KB) with some functionality in the same way as above mentioned its failing. I mean on ipm>> prompt if i try to load that new module added i am not getting required output.

For example in src/lib folder i have added another file called sample.py and i imported this file in main.py as above mentioned and after connectiong through serial cable i will run ipm command from tools/ directory as follows:
"python ipm.py -s com4" this command will redirect to ipm>> prompt and from that prompt if i try to load the sample module i am not getting any results and some times its halting..

Will somebody help me in this scenario and please guide me on how to add new script file to p14p modules and how to get that new file functionality from ipm prompt??

Thanks in advacne
Basha

Lucio Di Jasio

unread,
Jun 19, 2014, 11:41:59 AM6/19/14
to python-o...@googlegroups.com
Hi Basha,
After adding a new module to the lib (or other folder inside the platform) make sure to "regenerate" the pm_generated_obj.c and .h file by invoking the pmCoCreator.py tool adding the new module path to the list passed to the tool.

This must be performed before invoking the PIC32 compiler either manually or automatically if you are still using a SCONS script to handle your project build.

If you are using my project clone, this can be performed by invoking manually the "gen" bash script found in each PIC32 specific platform folder (Mikromedia, MMB-MX4, MMB-MX& etc)

Hope this helps
Lucio
> --
> --
> You are subscribed to the "python-on-a-chip" (or p14p for short) Google Group.
> Site: http://groups.google.com/group/python-on-a-chip
>
> ---
> You received this message because you are subscribed to the Google Groups "python-on-a-chip" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to python-on-a-ch...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

jani basha

unread,
Jun 20, 2014, 12:14:33 AM6/20/14
to python-o...@googlegroups.com, lucio....@googlemail.com
Hi Lucio,

Thanks for your reply and i am regenerating pm_generated_obj.c and .h file each time while compiling for PIC32 platform using 'gen' script given in platform specific folder. Even though i am not able to call more than one function after loading modules from ipm prompt.
My exact issue was i want to implement some functionality like user registration and user logout, so for this i have written two API's named as login(username,password) and logout() in "example.py" and i have added "example.py" file in src/lib directory and "gen" script for generating pm_generated_obj.c/.h files. 
After connecting to ipm prompt in src/tools i have written example_calling.py file which consists of importing "example.py" API's and written supported functions to call actual functions in "example.py"

In details i have flow of calling api's from IPM prompt as follows:

example.py --------------------> login(username,password) , logout()  [which is in src/lib directory]
example_calling.py ---------------------------> calling_login(username,password) , calling_logout()  [which is in src/tools directory]

After connecting to ipm from prompt i have situation as follows:

>>>load module example
>>>login("test1","test1")          =============> up to here functionality works well
>>>logout()                             =============> no functionality and ipm halts with some time giving Name Error or Memory Error etc

so is it having any constraints???


Thanks in advance,

Basha

jani basha

unread,
Aug 12, 2014, 2:51:46 AM8/12/14
to python-o...@googlegroups.com, lucio....@googlemail.com
Now i am working on P14P Memory issues.

I have some questions on this like:

Is there anyway we have chance to unload or delete module after making use of that module. I mean from ipm prompt>> we will use "load module" command to load our module into RAM permanently so after making use of this module we need to remove/delete this module from RAM. So is there anyway to do this in the current P14P development, if not could anybody please suggest me the way how to achieve this one because i am facing exact issue now.

After loading module multiple times from ipm prompt>> i am getting the following error due to insufficient memory.

After loading 2 or 3 times from ipm prompt i am getting the following error.

Traceback (most recent call first):
  File "../lib/ipm.py", line 97, in ipm
  File "main.py", line 19, in main
MemoryError detected by heap.c:444

Regards,
Jani Basha Shaik
Reply all
Reply to author
Forward
0 new messages