12 messages in net.java.dev.jna.usersRe: [jna-users] problem with useMemory()
FromSent OnAttachments
evgeni shafranMay 27, 2008 11:46 pm 
Paul LoyMay 28, 2008 2:04 am 
evgeni shafranMay 28, 2008 2:21 am 
Paul LoyMay 28, 2008 3:05 am 
Paul LoyMay 28, 2008 3:07 am 
evgeni shafranMay 28, 2008 3:36 am 
Paul LoyMay 28, 2008 3:40 am 
Paul LoyMay 28, 2008 3:44 am 
evgeni shafranMay 28, 2008 3:50 am 
Paul LoyMay 28, 2008 3:52 am 
Paul LoyMay 28, 2008 3:55 am 
evgeni shafranMay 28, 2008 3:57 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] problem with useMemory()Actions...
From:Paul Loy (kete@gmail.com)
Date:May 28, 2008 2:04:12 am
List:net.java.dev.jna.users

Don't you have to then call super.read(); ?

On Wed, May 28, 2008 at 7:46 AM, evgeni shafran <yavj@gmail.com> wrote:

hey, i trying to get structure from shared memory. the code compiles but it dont actualy reads from memory

import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure;; /** Simple example of native library declaration and usage. */ public class test { static Pointer sharedMemPointer ; static SharedData sd; public interface CLibrary extends Library{ CLibrary INSTANCE = (CLibrary) Native.loadLibrary( "c", CLibrary.class);

void printf(String format, Object... args); Pointer shmat(int shmid, final Pointer shmaddr, int shmflg); int shmget(int key, int size, int shmflg);

}

public static void main(String[] args) { ConnectToMemmory();

} public static void ConnectToMemmory() { sd= new SharedData(); int memId = CLibrary.INSTANCE.shmget((0x7a6d2000&0xffffff00)|28,36497932 , 00001000|0777); sharedMemPointer = CLibrary.INSTANCE.shmat(memId, null, 0); sd.useMemory(sharedMemPointer); System.out.println(sd.toString()); }

public static byte[] getByteRGBbyIndex(int indexID) { int arraySize=352*288*3;// shuld be taken from db return sharedMemPointer.getByteArray(arraySize*indexID, arraySize); } }

import com.sun.jna.Pointer; public class SharedData extends Structure { enum State { IDLE, PREALARM, ALARM, ALERT, TAPE } public int size; public boolean valid; public boolean active; public boolean signal; public int state; public int last_write_index; public int last_read_index; public int last_image_time; public int last_event; public int action; public int brightness; public int hue; public int colour; public int contrast; public int alarm_x; public int alarm_y; public byte[] control_state= new byte[256]; @Override protected void useMemory(Pointer m) { super.useMemory(m); } @Override protected void useMemory(Pointer m, int offset) { super.useMemory(m, offset); } }

why dont it reads from memory?