I stumbled over the hal.shm() method and got curious
what it does is:
- hal.shm(component, key, size) creates a shared memory segment through
rtapi_shmem_new()
- the getbuffer() method returns a Python buffer object, which is a kind of raw
memory R/W interface
- buffer objects support index and slicing, see below
- the component need not be ready (component.ready()) - it is used only for
hal.component() hal_init() side effect and its returned module id
so it's a shared-memory communications mechanism between HAL components and
potentially matching C code
ad-hoc Python access to a given shared memory segment looks potentially useful
there's no semaphore protection around r/w ops afaict, and the underlying
buffer protocol seems to be under discussion, and will be superseded by
memoryview
I'm a bit unsure what to make of this. Useful? Worth adding to documentation?
Any other clues?
-m
--- run in background ---
import hal
import time
key = 4711
size = 1000
c = hal.component("foo")
sm = hal.shm(c,key, size)
b = sm.getbuffer()
b[0] = 'x'
b[1:6] = 'abcde'
time.sleep(60)
--- then run this:
import hal
key = 4711
size= 1000
c = hal.component("bar")
sm = hal.shm(c,key,size)
b = sm.getbuffer()
print "b[0]", b[0]
print "b[1:6]",b[1:6]
------
http://docs.python.org/c-api/buffer.html
http://stackoverflow.com/questions/3422685/what-is-python-buffer-type-for
http://mail.python.org/pipermail/python-dev/2000-October/009974.html
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers