ctype in pymite

92 views
Skip to first unread message

Nilesh Vora

unread,
Jan 1, 2014, 1:03:05 AM1/1/14
to python-o...@googlegroups.com
Is it possible to use ctype function from pymite?
Have anyone done it before?

Dean Hall

unread,
Jan 1, 2014, 8:52:13 AM1/1/14
to python-o...@googlegroups.com
My understanding is that ctypes is a package that provides foreign function library for CPython.
No it is not possible to use this package from PyMite.

Based on this question and your previous questions, I feel I should help you adjust your expectations of p14p and PyMite.
1) The PyMite vm is not a scaled down version of CPython. PyMite is written from scratch to be as small as possible.
2) To fit in tiny RAM, PyMite is minimalist in what it supports. We only have a basic set of builtin functions and a tiny standard library.

From this perspective, the p14p programmer must realize that there is very little possibility of using code written for the desktop on a microcontroller with around 32K of RAM.

!!Dean


On Jan 1, 2014, at 12:03 AM, Nilesh Vora wrote:

> Is it possible to use ctype function from pymite?
> Have anyone done it before?
>
> --
> --
> 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/groups/opt_out.

Nilesh Vora

unread,
Jan 1, 2014, 11:26:16 AM1/1/14
to python-o...@googlegroups.com

Memory is not a issue with us. We have 512k ram on Marvell's MC200 borad. We have FreeRtos. We just want call c function from python script. The only problem we are facing is that we have to pass some structure to c function. But I am getting proper setting in pymite.

You received this message because you are subscribed to a topic in the Google Groups "python-on-a-chip" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-on-a-chip/KkXm5BFSzP0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-on-a-ch...@googlegroups.com.

Dean Hall

unread,
Jan 1, 2014, 11:46:05 AM1/1/14
to python-o...@googlegroups.com
I don't know what your structure looks like,
but you might consider building that structure within a Python String.
PyMite's String type uses a C array of uint8_t to hold the string.
PyMite also has a bytearray type, but it is not fully debugged.

For example, the C structure::

typedef struct
{
uint16_t x;
uint16_t y;
} coord_t;

coord_t start = {1, 2};

On a little endian processor, you could make the Python string:

s = "\x01\x00\x02\x00"

And in your native function copy the Python string's internal representation (uint8_t val[]) into your struct.

!!Dean
Reply all
Reply to author
Forward
0 new messages