Help porting python code to Xojo

Hi everyone. I’m a casual programmer, and there are gaps in my knowledge. I recently came across a gap with regards to memory maps. I have some code written in python access a memory map, and it works wonderfully. I’d like to know if anyone can help me port it to Xojo. The code is below:

import mmap
import struct

last=[]
while True:
    shmem = mmap.mmap(0, 20, "MumbleLink", mmap.ACCESS_READ)
    coord=struct.unpack("IL3f", shmem)[2:5]

    shmem.close()
    if last!=coord:
        print(coord)
        last = coord
        X = coord[2]
        Y = coord[0]
        Z = coord[1]

I’m hoping to expand my kowledge on shared memory and memory maps, but suspect it’s not going to be a quick thing. If anyone can help me here I’d appreciate it greatly,

Jason

HI Jason,

It looks like Memory Map is similar to Xojo’s Memory Block Object. I am not an expert compared to many on this thread, but I have used memory blocks quite a bit lately creating network protocols. I am not a python guy at all, so please see the link below and maybe that can get you started?

HTH!

http://documentation.xojo.com/index.php/MemoryBlock

Python newbie here. It looks like a Memory Map is a BinaryStream in Xojo. The characters that have been read are parsed from a struct into an array. But the format “IL3f” should be defined in your Python code somewhere.

Thanks for the help so far. Mike, the Xojo Memory Map seems to be private to the Xojo Ap. The python memory map is a shared memory map created by (in this instance) a third party.

Beatrix, any ideas how I could I use a Binarystream to open a shared memory memmap? It seems to have a name rather than an address - “MumbleLink”. As to the “IL3f” - the code you see is the entire python app - nothing more is defined in the code. It’s possible (probably even) that “Il3f” is defined somewhere in the included mmap library, but I wouldn’t know.

There’s no equivalent to shmem built in to Xojo
This literally lets several processes share a region of memory across the processes as means to communicate between them

There may be declares or a plugin that makes this possible
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/shm_open.2.html