Comments (21)
Wonderful. Works like a charm.
Thanks a lot for the effort.
from open-dis-python.
This is a pcap with the emission pdu's and a couple of entity state pdu's. Unfortunately that's all I have right now that is releasable to the internet. It's made by an outside company.
I have to figure out a way to create pdu's which I can share. Let met think about that.
from open-dis-python.
@ztolley Yes there are still many null's in the code base left over from the auto generated code tool. Over time I've been fixing the most obvious ones. The most commonly used pdu's have been fixed and don't have nulls anymore (e.g. Entity State, Signal, Transmitter, Fire, Detonation, Electronic Emission, etc). If there's a specific pdu you're trying to use that has a null in it let me know. And better yet, you're welcome to submit a PR for a particular fix to get things going in a hurry.
from open-dis-python.
I've had this issue before multiple times. All instances of null should be changed to None to match python3
from open-dis-python.
I've had this issue before multiple times. All instances of null should be changed to None to match python3
Previous versions of python did not support null() either. Python2 has also reached end of life as of January 2020.
I have made this change in my own code. I do not support these messages in my application currently nor have a need for them, so I have not tested the results thoroughly.
I am willing to submit a pull request but I believe this may be an issue with the tool used to generate this code (I believe similar to the unneeded semi colons but have not looked for the cause of either). I do not have time to fix all of these issues right now, but may be able to contribute a little bit if needed.
from open-dis-python.
A while back I fixed a number of occurences of null() in the code base that were causing issues.
It looks like this one was missed.
from open-dis-python.
@leif81 Shall I submit a pull request?
from open-dis-python.
Sure though I'm not sure None is the right replacement. Comparing this with the fix to the other null() fixes it looks like element
needs to be initialized to a the expected object type so that the right parse() method is called.
from open-dis-python.
If the java implementation is right then iffData is an array of bytes.
from open-dis-python.
My hunch is it may need to be changed to this
for idx in range(0, self.recordLength):
val = inputStream.read_byte()
self.iffData[ idx ] = val
from open-dis-python.
Sure though I'm not sure None is the right replacement. Comparing this with the fix to the other null() fixes it looks like
element
needs to be initialized to a the expected object type so that the right parse() method is called.
I agree with not changing them to None.
My hunch is it may need to be changed to this
for idx in range(0, self.recordLength): val = inputStream.read_byte() self.iffData[ idx ] = val
Based on the 2 previous commits referenced (99b7938, 10f241e), I believe we should be doing something more like this:
for idx in range(0, self.recordLength):
element = IffData()
element.parse(inputStream)
self.iffData.append(element)
There are still 31 different instances of null() which will need different versions of this. Another null() Example
from open-dis-python.
Edited Original post to reference
open-dis-python/opendis/dis7.py
Line 129 in 928becd
from open-dis-python.
Any of us happen to have a sample IFF Data PDU to use as reference to confirm ?
from open-dis-python.
So I stumbled upon this bug with the Electronic Emissions PDU. Does anyone have an indication when it will be solved? I understand everybody is busy but I need this fixed for specifically the EM PDU before march next year and I'm not sure I can do that myself.
from open-dis-python.
Hi @pulsebreaker thanks for the comment. Originally there were many instances of nulls in the code. There were more than I had time to fix all at once. So I've been fixing them in batches based on demand for particular pdus.
Electronic emission pdu is probably one I didn't do yet.
Could you share a sample electronic emission pdu packet from Wireshark? That would be very helpful to know if the change I make will work or not.
from open-dis-python.
Thanks for the quick response!
Here is a single EM system PDU. I might also have multiple EM systems PDU's if that's easier but I have to dig a little.
from open-dis-python.
@pulsebreaker thank-you for the sample. This was very helpful. I made a large change to the Electromagnetic Emission Pdu parser/serializer and used your sample packet in a unit test. Can you give it a try the latest code on master branch and let me know if it fixed the issue?
from open-dis-python.
It certainly is a very big step forward for me, thanks a lot!
However I'm receiving a new error:
aPdu = createPdu(data)
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\PduFactory.py", line 92, in createPdu
return getPdu(inputStream)
File "C:\Users\s...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\PduFactory.py", line 75, in getPdu
pdu.parse(inputStream)
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\dis7.py", line 5382, in parse
element.parse(inputStream)
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\dis7.py", line 5441, in parse
self.trackJamRecord.parse(inputStream);
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\dis7.py", line 2136, in parse
self.entityID.parse(inputStream)
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\dis7.py", line 3302, in parse
self.siteID = inputStream.read_unsigned_short();
File "C:\Users...\AppData\Local\Programs\Python\Python37-32\lib\site-packages\opendis\DataInputStream.py", line 35, in read_unsigned_short
return struct.unpack('>H', self.stream.read(2))[0]
struct.error: unpack requires a buffer of 2 bytes
It looks like it has to do with self.trackJamRecord.parse(inputStream).
Apparently it is possible for this PDU to have no targets in the Track or Jam field. If that's the case than the value self.numberOfTargetsInTrackJam = 0 and self.trackJamRecord.parse(inputStream) causes the struct unpack error.
I made a very cheap and dirty little change in dis7.py just to check my theory:
5441 if self.numberOfTargetsInTrackJam > 0:
5442 self.trackJamRecord.parse(inputStream);
With this ugly little addition the error is gone and on first sight it looks like it parses everything correctly.
Hope this helps.
Again, thanks a lot for all the work! Looks like I can proceed and finish my project in time after all.
from open-dis-python.
@pulsebreaker Ah Ok, I understand it now. Try it now I pushed a fix.
from open-dis-python.
Great news @pulsebreaker
Unrelated....Do you have other sample dis 7 packets you could share? I would add them to make our unit test coverage better.Any and all pdu types would be useful. But in particular entity state, fire, detonate, signal, transmitter, receiver would be really useful.
from open-dis-python.
I tried checking the code out and looking at dis7.py and it still has a bunch of null() calls, is this meant to be working?
from open-dis-python.
Related Issues (20)
- DataPdu Not finished - needs example HOT 1
- VariableDatum object cannot hold negative signed integers HOT 1
- EntityMarking only serializes 11 of 12 required bytes HOT 2
- Redundant fields cause serialization/parsing errors HOT 5
- Example does not function as it intended HOT 3
- Issue with dis_recieve.py createPdu() HOT 4
- Apply feedback to examples from Stackoverflow question
- VariableDatum object does not serialize padding HOT 3
- Divide by zero in RangeCoordinates.py HOT 3
- Allow for multiple receivers on same UDP address/port HOT 3
- ElectronicEmmisionsPdu does not handle beams correctly HOT 1
- Example sender isn't looping as suggested in README HOT 3
- SignalPdu Not Packing Data Correctly HOT 4
- Feature request: Local to Euler angles conversion HOT 2
- EmissionSystemBeamRecord.serialize incorrectly contains outputStream read calls instead of write
- Typographical Error in ReceiverPdu HOT 2
- Will this become a Pip package? HOT 11
- not an issue but a question surrounding performance HOT 1
- signed bytes in signal pdu HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-dis-python.