Search found 80 matches

by cduran
Wed Aug 17, 2016 4:41 pm
Forum: Development of MicroPython
Topic: How to fix script hanging?
Replies: 3
Views: 3530

How to fix script hanging?

I'm using MP as an embedded scripting engine for my firmware. I find that when there is an error in a script that MP waits in a loop and basically hangs my firmware. Is there a way to set micropython to just exit so that my firmware can continue regardless of script issues?
by cduran
Thu Jul 28, 2016 3:32 pm
Forum: General Discussion and Questions
Topic: C Structs in MP
Replies: 4
Views: 4145

C Structs in MP

I have several C structs in my firmware that need to be read and written to by both C and Python. Currently what I am doing is copying the structs into byte arrays and passing them by reference using a C callback. Is there a more efficient way of doing this?
by cduran
Wed Jul 13, 2016 8:37 pm
Forum: General Discussion and Questions
Topic: Using the C API?
Replies: 18
Views: 19451

Re: Using the C API?

Just one more question, in your example, how would I pass an argument(s) from python to C? ie. c_sample.call_callback(X, Y, ... )
by cduran
Wed Jul 13, 2016 3:27 pm
Forum: General Discussion and Questions
Topic: Using the C API?
Replies: 18
Views: 19451

Re: Using the C API?

Could I add more C callbacks without modifying mpconfigport.h? You only need to modify mpconfigport.h to add the module. Once the module has been added you can add as many methods to the module that you want by just modifying c_sample.c (or whatever you call your module). By convention, I probably ...
by cduran
Tue Jul 12, 2016 8:15 pm
Forum: General Discussion and Questions
Topic: Using the C API?
Replies: 18
Views: 19451

Re: Using the C API?

Could I add more C callbacks without modifying mpconfigport.h?
by cduran
Wed May 11, 2016 2:50 pm
Forum: Development of MicroPython
Topic: Passing variables between C and Python
Replies: 12
Views: 17889

Re: Passing variables between C and Python

The function mp_obj_new_bytearray https://github.com/micropython/micropython/blob/master/py/obj.h#L605 will allocate a bytearray and populate it with the data passed in. The mp_obj_new_bytearray_by_ref will allocate a bytearray object, but it will point to the data passed in. You can see the implem...
by cduran
Tue May 10, 2016 6:49 pm
Forum: Development of MicroPython
Topic: Passing variables between C and Python
Replies: 12
Views: 17889

Re: Passing variables between C and Python

I guess the details depend on who allocates the array (C or python). What type of data will live in the array? Python has some specialized types of arrays, like bytearray, and a more generic array of same sized items. The array will be allocated in C. It will be an array of same sized items, but a ...
by cduran
Tue May 10, 2016 6:04 pm
Forum: Development of MicroPython
Topic: Passing variables between C and Python
Replies: 12
Views: 17889

Re: Passing variables between C and Python

I think the uctypes are what I need. I just need to pass an array that the python code will operate on. The part I don't quite understand is how do I actually define that array in C. The documentation doesn't talk about the C side of things, unless I'm completely misunderstanding something.
by cduran
Wed May 04, 2016 7:09 pm
Forum: Development of MicroPython
Topic: Passing variables between C and Python
Replies: 12
Views: 17889

Passing variables between C and Python

I am very new to MP and to Python in general. Let me start by saying that I want to use MP to execute byte code that comes precompiled using the cross platform MP compiler. I want to be able to pass a C variable into and out of that byte code. Basically all my hardware will be handled in C, mostly b...
by cduran
Thu Mar 17, 2016 4:57 pm
Forum: Other Boards
Topic: Need help with Makefile for ATMEL SAMV7
Replies: 9
Views: 8442

Need help with Makefile for ATMEL SAMV7

I'm interested in building mp for the Atmel SAMV71. I've never really used gcc extensively and therefore not too familiar with how Make files are structured. I would like to know what changes do I need to make to the make file for the minimal build? Any help that you guys can provide will be appreci...