473,795 Members | 3,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

access to preallocated block of memory?

I am running python on VxWorks. In the course of operation, a vxworks
tasks writes to a reserved area of memory. I need access to this chunk
of memory from within python. Initially I thought I could simply
access it as a string but a string would reallocate and copy this chunk
of memory; which is not something I can have as it would waste a huge
amount of memory. We're talking about something like 40MB on a device
with limited RAM. I have been looking at array. It looks promising.
What's the best route to go here? Ideally, I would like to simply pass
in the address of the reserved block and a length, and have the memory
accessible.

Is there some existing python object/facility I can use or will I need
to create a custom module? Any tips, hints, or pointers would
certainly be appreciated!
Thanks,

Greg

Dec 14 '05 #1
14 2432
>>> vxworks tasks writes to a reserved area of memory.

Is it compatible with the mmap module ?

Dec 15 '05 #2
On 2005-12-15, Do Re Mi chel La Si Do <en************ **@OmclaveauO.c om> wrote:
vxworks tasks writes to a reserved area of memory.


Is it compatible with the mmap module ?


I've never written a VxWorks module, but it would only take a
dozen or two lines of code to write a Linux driver that would
impliment mmap() to allow a pre-defined block of address space
to be mapped into user space.

--
Grant Edwards grante Yow! Yow! I threw up on
at my window!
visi.com
Dec 15 '05 #3
So array can not map a pre-existing chunk of memory? I did not port
the mmap module because such semantics don't exist on VxWorks. Based
on comments thus far, it looks like mmap is my best bet here? Any
other options?

Dec 15 '05 #4
On 2005-12-15, Greg Copeland <gt********@gma il.com> wrote:
So array can not map a pre-existing chunk of memory?
Providing access to a pre-existing chunk of memory is an OS
feature. How does VxWorks provide that feature?
I did not port the mmap module because such semantics don't
exist on VxWorks.
Well then, what semantics _do_ exist on VxWorks?
Based on comments thus far, it looks like mmap is my best bet
here? Any other options?


Since we don't know how VxWorks provides access to an arbitrary
block of memory, how would we know how to use that VxWorks
feature from Python?

--
Grant Edwards grante Yow! I'm DESPONDENT... I
at hope there's something
visi.com DEEP-FRIED under this
miniature DOMED STADIUM...
Dec 15 '05 #5
On 14 Dec 2005 14:30:34 -0800, "Greg Copeland" <gt********@gma il.com> wrote:
I am running python on VxWorks. In the course of operation, a vxworks
tasks writes to a reserved area of memory. I need access to this chunk
of memory from within python. Initially I thought I could simply
access it as a string but a string would reallocate and copy this chunk
of memory; which is not something I can have as it would waste a huge
amount of memory. We're talking about something like 40MB on a device
with limited RAM. I have been looking at array. It looks promising.
What's the best route to go here? Ideally, I would like to simply pass
in the address of the reserved block and a length, and have the memory
accessible.

Is there some existing python object/facility I can use or will I need
to create a custom module? Any tips, hints, or pointers would
certainly be appreciated!


What have you gathered from people who have gone before? googling python vxworks
gives about 50k hits ;-)

Your post does not have enough info about your environment, but for
the sake of eliciting same, suppose you had a custom extension module
written in C that would give you the access to the "reserved area of memory"
that you want. So e.g. from the point of view of your python program, it looks
like a module you can import, e.g.,

import vxreservedmem

Ok, how does the module know where the "reserved area" is? Would you link
the C to some vx library interface to establish location and size? Or?
Is there already a python interface to provide some access?
Can there be more than one instance, so the module should be able to
give you multiple objects that you can use to access different areas?

Once you have an access-providing object, what kind of access do you require?
What is represented within the "memory area" besides an array of bytes? Do the
bytes represent C structs and primitive types? Are there access locks that
determine when it's safe to touch the bytes? A single lock for the whole area,
or individual locks for structs/subregions within the whole? Do you just need
read access or do you want to store info? How would you like to select
chunks of info? Just slices of byte arrays, or are there meaningful arrays
of numbers -- integer, floats, etc. or bit fields etc?

You could define a pure python vxresrvedmem module that just simulates the real
thing, to test ideas -- and to communicate more clearly to us what the problem is.

What modules/libraries do you have to give you access now from python to the vxworks
environment? A file system? /dev/magic_stuff? or /proc/magic_stuff or ?
Regards,
Bengt Richter
Dec 15 '05 #6
sam
I had a simular situation when I was writing Python routines to access
the the storage (SCSIPASSTHROUG H) layer provided by Windows XP. My
solution was to develope an extention in C that allocated all storage
buffers within the extension. Then I added access extensions to
controll reading and writing to and from these buffers. I would guess
that you can write a vxworks extension that provides this linkage.
Bengt Richter wrote:
On 14 Dec 2005 14:30:34 -0800, "Greg Copeland" <gt********@gma il.com> wrote:
I am running python on VxWorks. In the course of operation, a vxworks
tasks writes to a reserved area of memory. I need access to this chunk
of memory from within python. Initially I thought I could simply
access it as a string but a string would reallocate and copy this chunk
of memory; which is not something I can have as it would waste a huge
amount of memory. We're talking about something like 40MB on a device
with limited RAM. I have been looking at array. It looks promising.
What's the best route to go here? Ideally, I would like to simply pass
in the address of the reserved block and a length, and have the memory
accessible.

Is there some existing python object/facility I can use or will I need
to create a custom module? Any tips, hints, or pointers would
certainly be appreciated!


What have you gathered from people who have gone before? googling python vxworks
gives about 50k hits ;-)

Your post does not have enough info about your environment, but for
the sake of eliciting same, suppose you had a custom extension module
written in C that would give you the access to the "reserved area of memory"
that you want. So e.g. from the point of view of your python program, it looks
like a module you can import, e.g.,

import vxreservedmem

Ok, how does the module know where the "reserved area" is? Would you link
the C to some vx library interface to establish location and size? Or?
Is there already a python interface to provide some access?
Can there be more than one instance, so the module should be able to
give you multiple objects that you can use to access different areas?

Once you have an access-providing object, what kind of access do you require?
What is represented within the "memory area" besides an array of bytes? Do the
bytes represent C structs and primitive types? Are there access locks that
determine when it's safe to touch the bytes? A single lock for the whole area,
or individual locks for structs/subregions within the whole? Do you just need
read access or do you want to store info? How would you like to select
chunks of info? Just slices of byte arrays, or are there meaningful arrays
of numbers -- integer, floats, etc. or bit fields etc?

You could define a pure python vxresrvedmem module that just simulates the real
thing, to test ideas -- and to communicate more clearly to us what the problem is.

What modules/libraries do you have to give you access now from python to the vxworks
environment? A file system? /dev/magic_stuff? or /proc/magic_stuff or ?
Regards,
Bengt Richter


Dec 15 '05 #7
First, let me say thanks for answering...
What have you gathered from people who have gone before? googling python vxworks gives about 50k hits

And chances are, they will all be unrelated to my question. WRS uses
python for various IDE scripting needs, but they do not use it on their
own platform. Before I ported Python to VxWorks, AFAIK, it didn't
exist on that platform.
our post does not have enough info about your environment,
That's because I'm not asking someone to specifically tell me how to do
it on VxWorks. This is because I'm sure a VxWorks specific solution
does not exist. I'm asking about the best road to take given a generic
python environment. I added the extra information just in case someone
had some insight of the platform and python. If a generic answer does
not exist then I'm sure I'll have to craft something my self...which is
also part of what I'm trying to determine. The question is very
simple...aside from mmap, does there exist any
pre-existing facilities in python to which I can pass an address and an
length and have the associated chunk of memory exposed to python while
using an existing type, which does not attempt to malloc and copy?
Unless you have a specific answer which uses vxWorks specific
facilities, the fact that it's on VxWorks is strictly informational.
Once you have an access-providing object, what kind of access do you require?
It doesn't really matter. It just so happens that it's read only
access, but I can't see how it matters. Later on, it may require write
access too. I simply need to access the binary data byte for byte.
What modules/libraries do you have to give you access now from python to the vxworks environment?


As I said before, I have a chuck of memory, to which I have a pointer.
I know the length of the memory. I would like to obtain acecss to the
chuck of memory. Based on everything I'm seeing, it seems the answer
is a custom module, all the way; which I can probably base the mmap
module.

Sorry for any confusion my original question may of created. I was
rushed when I posted it. Hopefully this posting will be more clear as
to my intentions and needs.

Sincerely,

Greg

Dec 15 '05 #8
I think you're getting caught in OS/platform semantics rather than a
python solution. I already have access to the block on memory...I
simply need information about existing python facilities which will
allow me to expose the block to python as a native type...from which I
can read byte for byte and optionally write to. As I originally said,
I have a pointer and the block's length. I have access to it already.
I simply need to expose it to python. What facilities already exist to
allow this which do not cause malloc/memcpy on said block?

Thus far, it looks like a hack on mmap is my best bet...I was hoping
that the array module would have something I could use too; which would
prevent me from havining to write my own data type module.

Dec 15 '05 #9
Based on the answers thus far, I suspect I'll being traveling this road
shortly.

Thanks,

Greg

Dec 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4439
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or MBM http://mbm.livewiredev.com/ can be used. Both of the mentioned apps expose data got from the hardware in a shared memory area.
3
2517
by: Thomas Baier | last post by:
Hi there, I'v got a little program generating coincidental lists. It crashes with memory access failure, but not always at the same time. If I start the programm using valgrind it always crashes after sorting the first list with the following messages: thomas@linux:~/Info/C++> valgrind list /usr/bin/valgrind: line 106: exec: list: not found
9
3181
by: WalterR | last post by:
This is my first time here, so there may be earlier relevant threads of which I am unaware. Though my experience with DB2 is not extensive, such as it is was under OS/390 or equ. My main experience is IMS DB, which leads to my question. In IMS, there is an HDAM access method which can find a record without using an index as such. At initial database load, it first formats the entire space allocation into blocks of the given size. ...
24
3830
by: David Mathog | last post by:
If this: int i,sum; int *array; for(sum=0, i=0; i<len; i++){ sum += array; } is converted to this (never mind why for the moment):
6
2816
by: Cable | last post by:
Hello, I am hoping that someone can answer a question or two regarding file access. I have created an app that reads an image from a file then displays it (using OpenGL). It works well using fopen() with fgetc() to access each byte. I have decided to move further with this app and allow the user to select the first file of an image sequence and it will play the sequence back at at 24 frames per second. I have almost everything...
8
9764
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
1
2418
by: richardconnor | last post by:
Hi, Is it possible to get use of a block of contiguous memory using JavaScript? - I'd like to use it for a project but it's efficiency-critical and I want access to a memory-addressable block. If I use a big array will an implementation create a contiguous block or just build an associative lookup table? I have been told that in a web page people use the Flash plugin if it's available for this purpose - is this really true? In which case I...
3
1792
by: Sune | last post by:
Hi all, I'm not a C# programmer so please be gentle: Prereq: --------------- - The lookup service (see below) implemented by a C module cannot be re-written in C# ;-) - The lookup service is to be loaded into the process of the C# application, i.e. I want to avoid expensive IPC
5
2682
by: Mahendra Kumar Kutare | last post by:
I am trying to implement a webserver with boss-worker model thread pool implementation - I have a header declaration threadpool.h as - typedef struct threadpool_work { void (*routine) (); void *arg; struct threadpool_work *next; } threadpool_work_t;
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.