open-dis / open-dis-cpp Goto Github PK
View Code? Open in Web Editor NEWC++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
License: BSD 2-Clause "Simplified" License
C++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
License: BSD 2-Clause "Simplified" License
see
The code checks if pdu
is valid but dereferences it nonetheless if it is not.
Linux build instructions fail.
Steps to reproduce the behaviour:
premake5 gmake
in repo root directory.make config=release
and observe error.Make command succeeds.
Make fails fatally due to undocumented dependency in example code.
To make it easier for developers to use open-dis-cpp in their projects, it would be nice to add the library to the Conan repository.
/cc @wadehunk
I saw the recent CMake Pull Request #35, and after seeing @leif81's comments and questions, as well as the previously unaccepted CMake pull request #33, I thought it would be useful to create an issue for it to be discussed.
One query from Lief was if CMake worked well with Visual Studio, and in the past I have found it was quite well across platforms.
The second query was if CMake is typically verbose?
This is were I'm a little unsure on an answer because I'm kind of a CMake newbie myself, and I originally though it wasn't so verbose.
My impression is that it depends what you want it to do, and I'm hoping that is what this issue can clarify.
Here is a simplistic 50 line CMakeLists.txt that I wrote up a while back.
It creates 2 separate libraries OpenDIS7 & OpenDIS6, and 2 executable files using ExampleSender & ExampleReciever.
It also includes an install target that puts the libraries in an ${CMAKE_INSTALL_PREFIX}/lib
, executables in ${CMAKE_INSTALL_PREFIX}/bin
, and copies the head files to ``${CMAKE_INSTALL_PREFIX}/include. the
${CMAKE_INSTALL_PREFIX}` defaults to `/usr/local/` on my linux system, however it can be redirected by setting it in the cmake command. So building and installing might look something like this (Assuming the attached CMakeList.txt is in the root directory of open-dis-cpp)
cd open-dis-cpp
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/alternate/install/path/
make install # adding sudo if needed
However, some issues with my simplistic CMakeList.txt include:
So to sum up I think they needs to be a discussion, and decision on what requirements of the build system are, before a CMakeList.txt file is merged.
to avoid potential name clashes
e.g. in
ACKNOWLEDGEPDU_H
to DIS_ACKNOWLEDGEPDU_H
alternatively: use #pragma once
ExampleReciever should be corrected to ExampleReceiver
Unsigned/Signed integer compare compile warning.
Steps to reproduce the behavior:
premake5 gmake
in repo root directory.make config=release
and observe compile errors.Make works without error or warning.
Multiple minor compile warnings are raised.
ctrl-h over the source code and change "for( int idx" to "for( std::size_t idx". This would fix a lot of them. Obviously, care would need to be taken with each case to make sure the general change is correct in each instance.
void SignalPdu::marshal(DataStream &dataStream) const {
RadioCommunicationsFamilyPdu::marshal(
dataStream); // Marshal information in superclass first
dataStream << _encodingScheme;
dataStream << _tdlType;
dataStream << _sampleRate;
dataStream << (short)_data.size(); // ISSUE
dataStream << _samples;
for (auto byte : _data) {
dataStream << byte;
}
}
There is an issue related to the PDUs that inherit from the RadioCommunicationsFamilyPdu
(the IntercomSignalPdu
and SignalPdu
classes) where the size of the data being marshaled into the datastream is incorrect and not compliant with the DIS Standard. The data length should be the size of the data in bits (as per the SISO-STD-001-2015 standard), whereas the size being marshaled in currently is in bytes. I will open a PR to fix this issue.
It is possible that this issue is present elsewhere in the code, so I will do a once-over before requesting merge.
Building results in what looks like the same 97 error for the OpenDIS7 project - a bunch of LNK2019 & LNK2001 errors.
MS Windows VM - https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
Originally posted by @rodneyp290 in #37 (comment)
What about including the port of open-dis-cpp tp vcpkg (https://github.com/microsoft/vcpkg#contributing)?
open-dis-cpp/cpp/DIS/VariableDatum.cpp
Line 113 in 64200a2
There is no check for if _arrayLength is in fact larger than STATIC_ARRAY_LENGTH. If you get a VariableDatum larger than the allowed static array length, this blows in your face.
Thank you for your work!
Hello,
In DIS7/VariableDatum.h, variableDatumBits is an unsigned int
instead of std::vector<EightByteChunk>
/** Variable datum. This can be any number of bits long, depending on the datum. */
unsigned int _variableDatumBits;
it looks like DIS7/VariableDatium.cpp uses DIS/VariableDatum.h, so looks like this code isn't event compiling.
Thanks for your work!
open-dis-cpp/src/dis6/OneByteChunk.cpp
Lines 30 to 56 in 6e14b5f
Why have character arrays that will only ever contain a single character? Why use character arrays at all? A single character would suffice. There is no need to have these arrays that are "iterated" over. Seems very arbitrary and overly complicated. Will probably create a PR to update this, unless there is a justifiable reason to leave it the way it is.
OpenDIS segfaults on IncomingMessage::SwitchOnType (called by IncomingMessage::Process). Have come across this once on Windows and once on RHEL. First was while processing the DetonationPdu on Windows and second time was while processing EntityStatePdu on RHEL. (Using DIS6)
open-dis-cpp/src/utils/IncomingMessage.cpp
Lines 42 to 78 in 63b22b6
The problem was fixed when adding another processor leading me to believe somewhere the ->second
reference is reading off the end, but I have not looked into the specifics. It was always the last processor that failed and I do not believe those two messages were to blame but wanted to note it.
see
This doesn't work if PDU type is > max signed char (e.g. 250).
To me, the structure of the software is a bit unclear:
<DIS/...>
. This is probably not intended.cpp
and CppUtils
are both called DIS
. What will happen if a file with the same name exists in both directories (i.e. #include <DIS/...>
might easily include the wrong file)?As a result of this: How should, in your opinion, open-dis-cpp be installed for development on a Linux system?
In my opinion, these issues could be solved by:
#include <DIS/...>
becomes #include <open-dis/dis6/...>
)see
I tried building the Receiver-Example with DIS version 7. In order to do this I changed the target_link_libraries
from OpenDIS6
to OpenDIS7
. Furthermore I changed the Includes for the EntityStatePdu from #include <dis6/EntityStatePdu.h>
to #include <dis7/EntityStatePdu.h>
in EntityStatePduProcessor.h
and main_receive.cpp
.
When I try to build, I get an error about "type redefinition" of DIS::Pdu
. In my opinion this makes sense, since there is still the Include #include <dis6/utils/IncomingMessage.h>
. That include references dis6/Pdu.h
.
What exactly am I doing wrong? How can I change the example to use DIS version 7?
I have what feels like a dumb question.
I want to populate a variable length PDU SignalPdu with "fake" data and test it out.
e.g. I want to send an array of Ints, or 1 int for now.
I know that 1 int should get packed into a char array of size 4, int32 would be four bytes where each byte is an instance of OneByteChunk
in the std::vector which should then be of size 4.
I am confused how to do this, and any help would be appreciated.
open-dis-cpp/cpp/DIS/SignalPdu.cpp
Lines 98 to 114 in 86e8c24
There are multiple errors here. First of all "_dataLength" in interpreted incorrectly as bytes, when it's in fact bits / or a constant value when using the encoding scheme for database index.
From the standard: (emphasis added): "Data Length - This field shall specify the number of bits of digital voice audio or digital data being sent in this Signal PDU. This field shall be represented by a 16-bit unsigned integer. If the Encoding Class is database index, the Data Length field shall contain the value 96."
Also: "Data - This field shall specify the audio or digital data conveyed by the radio transmission. The interpretation of the Data field depends on the value of the Encoding Scheme (see 5.4.8.2(d)) and TDL Type (see 5.4.8.2(e)) fields."
How does error manifest itself? Basically you're trying to read/unmarshal too much data (8 times). If you have defined large enough buffer for DataStream, this problem goes undetected, but the extra data will be trash (just the contents of the read buffer). If you have a buffer sized according to the incoming PDU, this will cause undefined behaviour. Essentially DataStream will index over it's buffer.
There are similar problems in marshal. Data length f.e. will be encoded incorrectly.
e.g. in
#include <dis6/AcknowledgePdu.h>
to #include "AcknowledgePdu.h"
One day we can look at hooking up AppVeyor CI for the Windows build, just like we do with Travis for Linux.
Would be nice to have both setup to build on every change.
Originally posted by @leif81 in #37 (comment)
"I am considering applying Google Style Guide formatting to the code base for modern C++ style compliance, though I do not want to overstep my bounds."
Originally posted by @crhowell3 in #80 (comment)
Now that the OneByteChunk class has been refactored, I'd like to implement some clang-format and Google Style Guide compliance to this repository to clean up and modernize this code base without affecting the overall intent and functionality.
Hello,
Thanks for your contribution. As in my company needs DIS implementation, I currently work on DIS by using repository. When I encounter with some missing PDUs, I wanted to contribute as well.
According to these two documents from SISO, there should be IFF PDU:
I've already opened a pull request after I completely finish the PDU.
I am open any comments or reviews.
Thanks,
nearly everything contains one of these headers files "opendis6_export.h" and "opendis7_export.h"
but those header files do not exist in src directories, or any other directory that I've looked into.
Won't compile without them. If you comment out the include, then there are even more errors, because that's where symbols had been defined.
When compiling, I get "fatal error: 'DIS/DataStream.h' file not found" and if I "touch DIS/DataStream.h" I get multiple "error: unknown type name 'DataStream'"
How can I access to the raw data inside the variable datum? Looking at the code I am a little confused.
I mean SetDataPdu contains a std::vector and I can access to it but inside the VariableDatum I found the following
/** Type of variable datum to be transmitted. 32 bit enumeration defined in EBV */
unsigned int _variableDatumID;
/** Length, in bits, of the variable datum. */
unsigned int _variableDatumLength;
/** Variable datum. This can be any number of bits long, depending on the datum. */
unsigned int _variableDatumBits;
/** padding to put the record on a 64 bit boundary */
unsigned int _padding;
// Variable Data
std::vector<EightByteChunk> _variableDatums;
Looking on the standard, AFAIK or let me say as far as I understand, I don't see reference to EightByteChunk _variableDatums even if you marshal and unmarshall it, but no accessor method are provided....
Am I missing something?
How does it is supposed to be used?
For Java impl a getVariableData method exist, here (c++) how can I access the same data?
Also the getMarshalledSize seems to be wrong.
C++ looks like:
marshalSize = marshalSize + 4; // _variableDatumID
marshalSize = marshalSize + 4; // _variableDatumLength
marshalSize = marshalSize + 4; // _variableDatumBits
marshalSize = marshalSize + 4; // _padding
Java looks like:
marshalSize = marshalSize + 4; // variableDatumID
marshalSize = marshalSize + 4; // variableDatumLength
marshalSize = marshalSize + payload.length; // payload length
marshalSize = marshalSize + padding.length; // padding
For c++ seems we can add only 4 bytes....
Regards
Hello. I am able to run make
without any issues, both .so files and examples build. However, when I try to run make package
, cmake errors trying to build the RPM file. Is there a package that needs to be installed in order to continue?
Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux 5.11.0-37-generic
Architecture: x86-64`
$ make package
[ 43%] Built target OpenDIS6
[ 44%] Built target ExampleReceiver
[ 46%] Built target ExampleSender
[100%] Built target OpenDIS7
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: OpenDIS
CPack: - Install project: OpenDIS []
CPack: Create package
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
CPack: - package: /home/test/Desktop/open-dis-cpp/build/OpenDis-1.0.0.x86_64.deb generated.
CPack: Create package using RPM
CPack: Install projects
CPack: - Run preinstall target for: OpenDIS
CPack: - Install project: OpenDIS []
CPack: Create package
CMake Error at /usr/share/cmake-3.16/Modules/Internal/CPack/CPackRPM.cmake:774 (message):
RPM package requires rpmbuild executable
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/Internal/CPack/CPackRPM.cmake:1879 (cpack_rpm_generate_package)
CPack Error: Error while execution CPackRPM.cmake
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: OpenDis
make: *** [Makefile:141: package] Error 1
I want to build open-dis ccp dis6 source as a shared library. I don't need examples.
I am building on a machine that has cmake and most everything needed for development.
If this build is going to need more than I can not install that, need to work with what I have, which should be enough
anyhow, can I please have an example of linux command line to cmake and build
i tried ..
cmake -BUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -S src
(I'm sunning that in a directory that contains src/dis6, src/dis7 CMakeLists.txt
I tried using cmake3 as well
cmake -h doesn't help much :)
Do I need to make entries in CMakeLists?
I assumed, just download, install, and do cmake -S -B and turn on SHARED_LIBS,
but so far isn't working.
thanks
The Electronic Emission classes are misnamed as they are designated Electromagnetic Emission in the DIS standard.
The test directory has some test code in it, but the instructions are very vague.
it references cppunit, and set the path for cppunit.
It doesn't appear there are any build instructions.
how how would it be to add this to the cmake and enable a test variable?
is anyone using using the test directory?
TransmitterPdu is missing on include/dis7 though it is not deprecated in DIS 7 officially . In addition to this, it exists on Java repository OpenDIS Java.
I am implementing DIS by using this repository thanks to you, I realized that something is missing in Radio Transmission part because newly added PDUs does not completely represent Radio Transmission. Then I found DIS6 vs DIS7 PDF and it seemsTransmitterPdu has not been deprecated on DIS 7.
I also realized that if any Developer wants to use DIS 7:
If you can grant me access on some branch, I can work on that branch and make a pull request to you.
Hi there. My team and I are trying to use the examples given to build our own project but every time we try to implement anything within open like the DIS::IncomingMessages we get the following error:
"unresolved external symbol "__declspec(dllimport) ..."
We have all the header files in our project, linked OpenDIS.lib and copied OpenDIS.dll to the project folder. Are we missing something or is this a known issue when trying to build inside a project?
I tried to implement the IFFPdu, but it failed to form a correct stream. I managed to identify the issue with the code.
Under SystemIdentifier _systemMode shall be 8-bit, but it is defined as a unsigned short (16bit).
The correct declaration should be :
unsigned char _systemMode;
and corresponding gets and sets should change accordingly.
In my application, it's perfectly reasonable for, say, two different calls to find_dependency(OpenDIS)
to be made, which in turn causes OpenDISConfig.cmake
to be included twice. This is a bit of a problem, since then
## Add target aliases
add_library(OpenDIS::DIS6 ALIAS OpenDIS::OpenDIS6)
add_library(OpenDIS::DIS7 ALIAS OpenDIS::OpenDIS7)
## These are deprecated target names. All new references to the targets
## should utilize the new namespace wrapped version
add_library(OpenDIS6 ALIAS OpenDIS::OpenDIS6)
add_library(OpenDIS7 ALIAS OpenDIS::OpenDIS7)
gets run twice. The proposed fix is very straightforward, merely checking whether each target exists before creating it:
## Add target aliases
if (NOT TARGET OpenDIS::DIS6)
add_library(OpenDIS::DIS6 ALIAS OpenDIS::OpenDIS6)
endif()
if (NOT TARGET OpenDIS::DIS7)
add_library(OpenDIS::DIS7 ALIAS OpenDIS::OpenDIS7)
endif()
## These are deprecated target names. All new references to the targets
## should utilize the new namespace wrapped version
if (NOT TARGET OpenDIS6)
add_library(OpenDIS6 ALIAS OpenDIS::OpenDIS6)
endif()
if (NOT TARGET OpenDIS7)
add_library(OpenDIS7 ALIAS OpenDIS::OpenDIS7)
endif()
Would be nice to have a versioned release of open-dis-cpp to support configuration management use cases for users of the library. Would recommend using semantic versioning to capture API breakages.
it seems some files are missing.
eg: DIS/msLibMacro.h can't be found.
DIS/SyntheticEnvironmentFamilyPdu.h
I'm not terribly familiar with the HawkNL library, but from what I can tell it used to be very popular, but looks to be no longer maintained and fallen out of popularity. So to get the Examples
code compiling we may want to pick a replacement library.
I don't do much C++ dev these days, so I'm out of the loop in terms of what people actually use, but a couple potential replacement options that may be suitable are Boost (Asio) and SDL2 (SDL_net).
http://www.boost.org/doc/libs/1_64_0/doc/html/boost_asio.html
https://www.libsdl.org/projects/SDL_net/
Avoid that PR merges clutter the commit history (e.g. the merge of #31).
see https://help.github.com/en/articles/configuring-commit-squashing-for-pull-requests
I'm having trouble passing a std::vector from a QT project to the setter function by reference. compiling the projects with C++14 and MSVC 2019 Debug mode.
These are the functions I'm trying to use from the EntityStatePdu class:
std::vector& getArticulationParameters();
const std::vector& getArticulationParameters() const;
void setArticulationParameters(const std::vector& pX);
When I pass a std::vector variable from QT, it seems to have a different binary layout on MSVC.
Could it possibly be a compiler option that I have to match with OpenDIS in order to pass the same std::vector?
There should be 3 packages:
I'm not sure if/how this is possible with premake. An alternative would be CMake (CPack).
These packages could then also be released via GitHub releases.
Currently, the PDUBank (and thus the available PDUs) is hardcoded in
As a consequence, it is not possible to use a different PDUBank without changing the code. However, this is required e.g. to use DIS 7 PDUs.
I suggest to implement the PDUBank handling in a similar way to the PacketProcessors, i.e.
Pdu* GetStaticPDU(const DataStream&) const
IncomingMessage::AddProcessor
This would also help reducing the cyclic dependencies between the PDUs and the utils.
Inside the implementation of EntityStatePdu I discovered that the marshalled size of the PDU is calculated assuming to be present always only one articulation parameter. This is true for DIS6 and DIS7.
{
int marshalSize = 0;
marshalSize = EntityInformationFamilyPdu::getMarshalledSize();
marshalSize = marshalSize + _entityID.getMarshalledSize(); // _entityID
marshalSize = marshalSize + 1; // _forceId
marshalSize = marshalSize + 1; // _numberOfArticulationParameters
marshalSize = marshalSize + _entityType.getMarshalledSize(); // _entityType
marshalSize = marshalSize + _alternativeEntityType.getMarshalledSize(); // _alternativeEntityType
marshalSize = marshalSize + _entityLinearVelocity.getMarshalledSize(); // _entityLinearVelocity
marshalSize = marshalSize + _entityLocation.getMarshalledSize(); // _entityLocation
marshalSize = marshalSize + _entityOrientation.getMarshalledSize(); // _entityOrientation
marshalSize = marshalSize + 4; // _entityAppearance
marshalSize = marshalSize + _deadReckoningParameters.getMarshalledSize(); // _deadReckoningParameters
marshalSize = marshalSize + _marking.getMarshalledSize(); // _marking
marshalSize = marshalSize + 4; // _capabilities
for(unsigned long long idx=0; idx < _articulationParameters.size(); idx++)
{
ArticulationParameter listElement = _articulationParameters[idx];
marshalSize = marshalSize + listElement.getMarshalledSize();
}
return marshalSize;
}
As is possible to see the number of articulation parameters is stubbed to one when instead it should be _articulationParameters.size().
Hello,
I'm trying to build library in DIS7 on Win10 with mingw730_64 and have the following error :
src/dis7/VariableDatum.cpp:61:35: error: '_variableDatums' was not declared in this scope
Indeed, the variable _variableDatums
is not declared in the header file and not initialize in the constructor.
After adding it in both file, i have an other error :
src/dis7/VariableDatum.cpp:66:9: error: 'EightByteChunk' was not declared in this scope
The header variableDatum.h
don't include 'EightByteChunk'
After adding it, I have the following error :
src/dis7/VariableDatum.cpp:66:47: error: conversion from 'const value_type {aka const char}' to non-scalar type 'DIS::EightByteChunk' requested
EightByteChunk x = _variableDatums[idx];
Do you have any idea, how to fix it ?
I suggest you to add an appVeyor for your continuous integration indeed, you only test it on Linux with DIS6.
I have no problem with the DIS6
Thanks for your work !
The link to the HawkNL library in the CPP example (http://www.hawksoft.com/hawknl/) returns 404
HTTP error code.
I see from within the Sender, the setPduType has been commented out. Further more, even when uncommenting, the Receiver doesn't extract the PDU Type, among Exercise ID as well.
There is an issue related with the unmarshal function in incomingMessage if the dis packet is malformed.
Application crashes with some udp packets with malformed lenght field.
In concrete it seems that occurs if the lenght is greater than expected at this location:
void Pdu::unmarshal(DataStream& dataStream)
{
dataStream >> _protocolVersion;
dataStream >> _exerciseID;
dataStream >> _pduType;
dataStream >> _protocolFamily;
dataStream >> _timestamp;
dataStream >> _length; // <----- length malformed , greater than expected
dataStream >> _padding;
}
After this code execution, the exectution continues in the final class (i.e. EntityStatePdu::unmarshall) and the application crashes. I think It is because the malformed length, as it seems to be used en EntityStatePdu...
This is an example of a udp packet causing a crash: 0x020001020000001d2500167374642d7363616e....
I am trying to better understand the dis6 and dis7 implementations, but there appears to be a lot of overlap or duplication or things missing from one to the other.
My original thought was to create a common directory that would hold all the classes that are common to both versions, but have hit some roadblocks.
An an example would be the PDU header. the main difference i see is a variable that is padding in dis6 (uint16), but the same amount of bits is split into two variables in dis7 ( 2 x unint8). someone implemented a superclass in dis7 which PduHeader inherits and fills in the changed parameters, and the correct change in the dis6 code would be to have it inherit the same superclass and only add the padding. This is the direction that seemed to make sense until I hit places where the names have been changed. There appears to be classes that exist in dis6, and not in dis7 and vice versa, some appear to be name changes. e.g. Orientation versus EulerAngles. (although not sure about that one being a naming or duplication issue)
The problem that I have run into is that the reference document I am looking at to compare the versions is incomplete. siso document v6 vd v7
I thought this might be an issue with the underlying xml specification that generated the original code? I tried to decipher it, but I am not sure which tool generated this c++ code?
Any help or direction is appreciated.
I know there has been a lot of churn in the DIS7 implementation in recent months, but when is this anticipated to be fully DIS7 compliant? Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.