Note that WireShark seems to decode DataPdus incorrectly, as far as I can tell. It has some problems
on alignment of VariableDatums in the DataPdu.
The FixedDatum API is a little clunky. It expects a long for the value of the fixed datum set,
which doesn’t work well in Java. It’s probably easier to send Floats and Doubles as VariableDatums,
or you can go through the dance to convert a float or double to the equivalent bit value of a long
in FixedDatum, probably with some bit-masking and shifting.
Note that issues like byte order are up to your applications when sending data this way, as is
sorting out what the IDs of the various datums will be.
I recognize this post is old but I came here wondering how to encode floats as ints for packaging in fixed datums using java. The simple answer I eventually found (and the post did help) was to convert each float / double to a byte array and then the byte array to an int. With this little bit of additional understanding, fixed datums work great in open dis and the use of java creates no special problems that I have been able to find.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I recognize this post is old but I came here wondering how to encode
floats as ints for packaging in fixed datums using java. The simple answer
I eventually found (and the post did help) was to convert each float /
double to a byte array and then the byte array to an int. With this little
bit of additional understanding, fixed datums work great in open dis and
the use of java creates no special problems that I have been able to find.
Hi Leif,
This is good information.I was actually using open-dis 4.09. I did recently pull this old code and update it to fix a crashing issue in VariableDatum.java at line 114. It seems from a quick read that I could have just updated to the git hub project and also got other nice features such as the removal of all the unused imports. I will do this soon and report back if I find any problems.
Thank you for all your hard work on this project.
Robert
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, the original source code was created from an XML description
of the classes and attributes. That made it easy to generate
implementations for other languages (C++, Javascript, a few others)
that works reasonably well, but it's not really practical to regenerate
code libraries by applying Unix-style patches when a lot of people
don't run Unix and are thus unable to fix it. The update process
for cross-platform dev environments is just too annoying and
complex, though it would be nice to have any future languages
generated correctly.
So just working with the code generated by the older XML template
is the way to go. Doing git updates to the central repo is good and
not that obscure.
From: robert j ducharme robertjducharme@users.sourceforge.net
Sent: Sunday, January 28, 2018 6:40:33 PM
To: [open-dis:discussion]
Subject: [open-dis:discussion] DataPDU Example?
Hi Leif,
This is good information.I was actually using open-dis 4.09. I did recently pull this old code and update it to fix a crashing issue in VariableDatum.java at line 114. It seems from a quick read that I could have just updated to the git hub project and also got other nice features such as the removal of all the unused imports. I will do this soon and report back if I find any problems.
Does anyone have an example of creating / sending a DataPDU? (C# preferred)
I want to create a DataPDU with 10 fixed (4 int, 6 float) and 1 variable (string) datums and I’m not understanding the DataPDU datum constructs.
Any help would be appreciated.
Mike
Last edit: Mike 2014-06-03
Checked in an example program, attached.
Note that WireShark seems to decode DataPdus incorrectly, as far as I can tell. It has some problems
on alignment of VariableDatums in the DataPdu.
The FixedDatum API is a little clunky. It expects a long for the value of the fixed datum set,
which doesn’t work well in Java. It’s probably easier to send Floats and Doubles as VariableDatums,
or you can go through the dance to convert a float or double to the equivalent bit value of a long
in FixedDatum, probably with some bit-masking and shifting.
Note that issues like byte order are up to your applications when sending data this way, as is
sorting out what the IDs of the various datums will be.
Attached.
On Jun 3, 2014, at 4:39 AM, Mike m-warren@users.sf.netamp#109;amp#45;amp#119;amp#97;amp#114;amp#114;amp#101;amp#110;amp#64;amp#117;amp#115;amp#101;amp#114;amp#115;amp#46;amp#115;amp#102;amp#46;amp#110;amp#101;amp#116; wrote:
Does anyone have an example of creating / sending a DataPDU?
I want to create a DataPDU with 10 fixed (4 int, 6 float) and 1 variable (string) datums and I�m not understanding the DataPDU datum constructs.
Any help would be appreciated.
Mike
DataPDU Example?https://sourceforge.net/p/open-dis/discussion/general/thread/bdeebb8f/?limit=25#6551
Sent from sourceforge.nethttp://sourceforge.net because you indicated interest in https://sourceforge.net/p/open-dis/discussion/general/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
I recognize this post is old but I came here wondering how to encode floats as ints for packaging in fixed datums using java. The simple answer I eventually found (and the post did help) was to convert each float / double to a byte array and then the byte array to an int. With this little bit of additional understanding, fixed datums work great in open dis and the use of java creates no special problems that I have been able to find.
Hi Robert,
Have you looked at the implementation in the DataPdu.java class in the
open-dis-java GitHub project?
https://github.com/open-dis/open-dis-java/blob/master/src/main/java/edu/nps/moves/dis/DataPdu.java
Last summer it got some fixes and a unit test. I've used it in a project
myself with success.
https://github.com/open-dis/open-dis-java/blob/master/src/test/java/edu/nps/moves/dis/DataPduTest.java
If you find issues feel free to file an issue in the GitHub project.
Cheers
Leif.
On Sun, Jan 28, 2018 at 4:40 PM robert j ducharme robertjducharme@users.sourceforge.net wrote:
Hi Leif,
This is good information.I was actually using open-dis 4.09. I did recently pull this old code and update it to fix a crashing issue in VariableDatum.java at line 114. It seems from a quick read that I could have just updated to the git hub project and also got other nice features such as the removal of all the unused imports. I will do this soon and report back if I find any problems.
Thank you for all your hard work on this project.
Robert
Yes, the original source code was created from an XML description
of the classes and attributes. That made it easy to generate
implementations for other languages (C++, Javascript, a few others)
that works reasonably well, but it's not really practical to regenerate
code libraries by applying Unix-style patches when a lot of people
don't run Unix and are thus unable to fix it. The update process
for cross-platform dev environments is just too annoying and
complex, though it would be nice to have any future languages
generated correctly.
So just working with the code generated by the older XML template
is the way to go. Doing git updates to the central repo is good and
not that obscure.
From: robert j ducharme robertjducharme@users.sourceforge.net
Sent: Sunday, January 28, 2018 6:40:33 PM
To: [open-dis:discussion]
Subject: [open-dis:discussion] DataPDU Example?
Hi Leif,
This is good information.I was actually using open-dis 4.09. I did recently pull this old code and update it to fix a crashing issue in VariableDatum.java at line 114. It seems from a quick read that I could have just updated to the git hub project and also got other nice features such as the removal of all the unused imports. I will do this soon and report back if I find any problems.
Thank you for all your hard work on this project.
Robert
DataPDU Example?
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/open-dis/discussion/general/
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/
Don and Leif,
I took your advice and updated to the git hub project. It works great. Easy to build and no bugs that I've been able to find.
Thank You!
Robert