

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
29 messages in net.java.dev.jna.usersRe: AW: AW: AW: [jna-users] Struct wi...| From | Sent On | Attachments |
|---|---|---|
| Wolfgang Pichler | Mar 25, 2009 5:58 am | |
| Timothy Wall | Mar 25, 2009 7:02 am | |
| Timothy Wall | Mar 25, 2009 7:06 am | |
| Wolfgang Pichler | Mar 25, 2009 7:21 am | |
| Timothy Wall | Mar 25, 2009 7:24 am | |
| Wolfgang Pichler | Mar 25, 2009 8:11 am | |
| Wolfgang Pichler | Mar 25, 2009 8:20 am | |
| Novatchkov Hristo | Mar 25, 2009 8:41 am | |
| Timothy Wall | Mar 25, 2009 9:59 am | |
| Timothy Wall | Mar 25, 2009 10:28 am | |
| Timothy Wall | Mar 25, 2009 10:38 am | |
| Hristo Novatchkov | Mar 25, 2009 11:40 am | |
| Wolfgang Pichler | Mar 25, 2009 12:02 pm | |
| LYou...@gkservices.com | Mar 25, 2009 12:11 pm | |
| Timothy Wall | Mar 25, 2009 12:52 pm | |
| Wolfgang Pichler | Mar 26, 2009 12:22 am | |
| Timothy Wall | Mar 26, 2009 4:46 am | |
| Wolfgang Pichler | Mar 26, 2009 5:23 am | |
| Timothy Wall | Mar 26, 2009 6:09 am | |
| Wolfgang Pichler | Mar 26, 2009 6:13 am | |
| Wolfgang Pichler | Mar 26, 2009 6:26 am | |
| Timothy Wall | Mar 26, 2009 6:40 am | |
| Wolfgang Pichler | Mar 26, 2009 12:22 pm | |
| Timothy Wall | Mar 26, 2009 1:00 pm | |
| Wolfgang Pichler | Mar 26, 2009 3:15 pm | |
| Timothy Wall | Mar 30, 2009 6:06 am | |
| Wolfgang Pichler | Mar 30, 2009 11:55 am | |
| Timothy Wall | Mar 30, 2009 12:14 pm | |
| Wolfgang Pichler | Mar 31, 2009 12:35 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: AW: AW: AW: [jna-users] Struct with Union with Structs... | Actions... |
|---|---|---|
| From: | Wolfgang Pichler (wpic...@yosd.at) | |
| Date: | Mar 26, 2009 12:22:46 am | |
| List: | net.java.dev.jna.users | |
Hi,
yep - that is the problem. The data is incorrect - better to say - there is no data where there should be data. The fields are all filled with 0 values. If i don't use the union - but directly the sub event structure - then i do have the data. So the problem must be with using the union.
I can provide the full source if it would help.
regards, Wolfgang
Am Mittwoch, den 25.03.2009, 15:53 -0400 schrieb Timothy Wall:
I just wanted to check to see that the union fields were all correctly aligned with the start of the union. That is the case, so something else must be the problem if you're reading back a union field and the data appears to be incorrect. That *is* the problem, right?
On Mar 25, 2009, at 3:03 PM, Wolfgang Pichler wrote:
I am not sure if i have understood you right - but here is what I have tried
Here is the source
System.out.println("Event Raw: " + event.toString()); System.out.println("Event Event Raw: " + event.ev.toString()); event.ev.setType(IAXClient.iaxc_ev_registration.class); event.ev.read(); IAXClient.iaxc_ev_registration reg = (IAXClient.iaxc_ev_registration) event.ev.getTypedValue(IAXClient.iaxc_ev_registration.class); reg.reply = 2; reg.writeField("reply"); Object reply = reg.readField("reply"); System.out.println("Event Reg: " + reg.toString());
The event.ev.toString gives me
Event Event Raw: IAXClient$iaxc_event_union(allocated@0x2fc8c08 (12 bytes) (shared from allocated@0x2fc8c00 (20 bytes) (shared from allocated@0x2fc8c00 (20 bytes)))) { IAXClient$iaxc_ev_registration registration@0=IAXClient$iaxc_ev_registration(allocated@0x2fc8c20 (12 bytes)) { int id@0=0 int reply@4=0 int msgcount@8=0 } IAXClient$iaxc_ev_levels levels@0=IAXClient$iaxc_ev_levels(allocated@0x2fc2760 (8 bytes)) { float input@0=0.0 float output@4=0.0 } } memory dump [00000000] [00000000] [00000000]
After the write and read operation I have this
Event Reg: IAXClient$iaxc_ev_registration(allocated@0x2fc8c08 (12 bytes) (shared from allocated@0x2fc8c08 (12 bytes) (shared from allocated@0x2fc8c00 (20 bytes) (shared from allocated@0x2fc8c00 (20 bytes))))) { int id@0=0 int reply@4=2 int msgcount@8=0 } memory dump [00000000] [02000000] [00000000]
So it was written correctly...
But I don't understand what this has to do with my problem...
I can provide the whole source code with test code (its not that much at time) if this would help...
Regards, Wolfgang
-----Ursprüngliche Nachricht----- Von: Timothy Wall [mailto:twal...@dev.java.net] Gesendet: Mittwoch, 25. März 2009 18:29 An: use...@jna.dev.java.net Betreff: Re: AW: AW: [jna-users] Struct with Union with Structs...
It's not actually an issue; the structure fields' memory offset gets synched to the enclosing memory when the enclosing memory is read or written. See what the values are after a read/write (note that a read/ write on a union is a no-op if it doesn't have an active type as set by setType).
On Mar 25, 2009, at 11:20 AM, Wolfgang Pichler wrote:
Hi,
i have now seen that when using union i do have 2 different base addresses for the two possible structs - that is wrong, or ? The should be equal if I am not wrong.
Also the base address should be 0x3f8810 - and not 0x3f8ff0 or 0x3f87c0
I am right with this ?
-----Ursprüngliche Nachricht----- Von: Wolfgang Pichler [mailto:wpic...@callino.at] Gesendet: Mittwoch, 25. März 2009 16:12 An: 'use...@jna.dev.java.net' Betreff: AW: AW: [jna-users] Struct with Union with Structs...
Hi,
this is what i get when I use the union as struct member
Event Raw: IAXClient$iaxc_event_struct $iaxc_event_union(allocated@0x3f8810 (12 bytes) (shared from allocated@0x3f8808 (20 bytes) (shared from allocated@0x3f8808 (20 bytes)))) { IAXClient$iaxc_ev_registration registration@0=IAXClient$iaxc_ev_registration(allocated@0x3f8ff0 (12 bytes)) { int id@0=0 int reply@4=0 int msgcount@8=0 } IAXClient$iaxc_ev_levels levels@0=IAXClient$iaxc_ev_levels(allocated@0x3f87c0 (8 bytes)) { float input@0=0.0 float output@4=0.0 } } memory dump [00000000] [00000000] [00000000]
And here is what I get when directly using the registration struct as struct member
Event Raw: IAXClient$iaxc_ev_registration(allocated@0x2fc8ca0 (12 bytes) (shared from allocated@0x2fc8c98 (20 bytes) (shared from allocated@0x2fc8c98 (20 bytes)))) { int id@0=1 int reply@4=18 int msgcount@8=-1 } memory dump [01000000] [12000000] [ffffffff]
As far as I can see it does look correct to me...
Regards, Wolfgang
-----Ursprüngliche Nachricht----- Von: Timothy Wall [mailto:twal...@dev.java.net] Gesendet: Mittwoch, 25. März 2009 15:25 An: use...@jna.dev.java.net Betreff: Re: AW: [jna-users] Struct with Union with Structs...
Check to see that the union field has the proper base address, which should be some offset from the enclosing structure's base address. All union field members will have the same base address as the union.
On Mar 25, 2009, at 10:21 AM, Wolfgang Pichler wrote:
The code does not produce an exception or a crash... - but it does return wrong values.
I will return nulled values - but there are real values - as I have seen when I do directly use the registration structure instead of the union. It does look like it does not get initialized...
Regards, Wolfgang
-----Ursprüngliche Nachricht----- Von: Timothy Wall [mailto:twal...@dev.java.net] Gesendet: Mittwoch, 25. März 2009 15:07 An: use...@jna.dev.java.net Betreff: Re: [jna-users] Struct with Union with Structs...
On Mar 25, 2009, at 8:59 AM, Wolfgang Pichler wrote:
Here is the callback function IAXClient.INSTANCE.iaxc_set_event_callback(new IAXClient.FUNCTION() { @Override public int invoke(iaxc_event_struct.ByValue event) { if (event==null) { return 0; } switch(event.type) { case IAXClient.IAXC_EVENT_REGISTRATION: System.out.println("Event Raw: " + event.ev.toString());
event.ev.setType(IAXClient.iaxc_ev_registration.class); event.ev.read(); IAXClient.iaxc_ev_registration reg = (iaxc_ev_registration) event.ev.getTypedValue(IAXClient.iaxc_ev_registration.class); System.out.println("Event Reg: " + reg.reply); break;
Once you've called "read", you can simply access the corresponding union field. getTypedValue is a shortcut for setType + read. How exactly does this code fail?







