Code Monkey home page Code Monkey logo

modelica-3rdparty / modelica_devicedrivers Goto Github PK

View Code? Open in Web Editor NEW
75.0 18.0 30.0 23.55 MB

Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.

License: BSD 3-Clause "New" or "Revised" License

Modelica 51.00% CMake 2.97% C 36.66% C++ 0.67% Makefile 1.42% Shell 0.08% Motoko 7.20%
modelica modelica-library mqtt mqtt-client iot hacktoberfest

modelica_devicedrivers's Introduction

Modelica_DeviceDrivers

Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, TCP/IP, LCM, MQTT, shared memory, AD/DA converters, serial port and other devices.

Library description

The Modelica_DeviceDrivers (MDD) library is an open source Modelica package that interfaces hardware drivers to Modelica models. An overview of the library is provided in

Bernhard Thiele, Thomas Beutlich, Volker Waurich, Martin Sjölund, and Tobias Bellmann, Towards a Standard-Conform, Platform-Generic and Feature-Rich Modelica Device Drivers Library. In Jiří Kofránek and Francesco Casella, editors, 12th Int. Modelica Conference, Prague, Czech Republic, May 2017. Download

The library unifies previous developments concerning device driver support in Modelica, see Interactive Simulations and advanced Visualization with Modelica and Modelica for Embedded Systems (Modelica'2009 conference). The functionality covered by this library has been used internally at DLR for several years, such as for Driver-in-the-Loop simulation and for the DLR Robot Motion Simulator. The previously fragmented functionality was streamlined, improved, and extended to a coherent cross-platform library.

Main features:

  • Cross-platform (Windows and Linux).
  • (Soft) real-time synchronization of a simulation.
  • Support for keyboard, joystick/gamepad, and 3Dconnexion Spacemouse.
  • Support for a universal packaging concept to pack Modelica variables in a graphical and convenient way into a bit vector and transport such a bit vector via UDP, TCP/IP, LCM, MQTT, serial I/O or shared memory (CAN support is prototypical available).
  • Support of the Linux control and measurement device interface for digital and analog I/O (Comedi interface).

All device drivers are made available via external Modelica functions. Furthermore, high level interfaces on these functions are provided via Modelica blocks. The first interface uses Modelica 3.2 functionality only (when-clauses and sample-operator). The second interface uses the synchronous language elements introduced in Modelica 3.3 and is based on clocks.

BlockOverview

Self-certification

  • Internationalized
  • Unit tests
  • End-user documentation
  • Internal documentation (documentation, interfaces, etc.)
  • Existed and maintained for at least 6 months

Build status

Build Status

Current release

Download Modelica_DeviceDrivers latest release

Please note that the library is known to work with

  • Dymola,
  • SimulationX (with userBufferSize all non-clocked communication blocks are working in SimulationX, but autoBufferSize only works for external solvers CVode and Fixed Step solver and fails for BDF and MEBDF solvers, see #54 (comment)),
  • OpenModelica (partial support, e.g., UDP, serial port, shared memory, LCM, keyboard).

If you tested the library successfully with another Modelica tool, please contact Bernhard Thiele or send a pull request that updates this README.md.

Release notes

Bug fix releases may not have release notes, so please use the download link from above to get the latest release including bug fixes.

  • Version v2.1.0 (2022-08-10)
    • Enhancements:
      • Added parameter useRecvThread also for clocked UDPReceive variant (#342).
      • Added option for not unlinking shared memory partition at process termination (#339).
      • Updated 3rd-parth library paho.mqtt.c to v1.3.10 (#355).
    • Bug fixes:
      • Fixed sporadic RealtimeSynchronize block "clock_nanosleep" error on Linux (#357).
      • Fixed MDD_TCPIPServer_Send(...) return value, so that it works as described in the documentation: "On success, return the number of bytes sent, 0 if operation would block, -1 on non-fatal error" (#323).
      • Serial port interface on Windows: Fixed spurious byte sent at the end of a simulation (#352).
  • Version v2.0.0 (2020-06-08)
    • Migrated from Modelica Standard Library 3 (MSL 3) to MSL 4 -> Non-backwards compatible release!
    • However, apart from the MSL 4 dependency this release is compatible to previous releases and no update of user libraries is necessary apart from migrating to MSL 4.
    • Enhancements:
      • Added all license files to better assist tool vendors in distribution of source or binary files (#313).
      • Updated 3rd-party library paho.mqtt.c to v1.3.4 (#320).
    • Bug fixes:
      • Fixed small issues in the SBHS Board example (#318).
  • Version v1.8.2 (2020-03-26)
    • Updated Linux MQTT binary dependencies. The updated libraries are compiled with the -fPIC flag, which fixes a related FMU generation problem (#306).

For information about previous releases, see Release Notes of Previous Versions.

Citing

Use the following BibTeX lines to cite the Modelica_DeviceDrivers library

@InProceedings{modelica2017mdd,
  Title = {Towards a Standard-Conform, Platform-Generic and Feature-Rich Modelica Device Drivers Library},
  Author = {Thiele, Bernhard and Beutlich, Thomas and Waurich, Volker and Sjölund, Martin and Bellmann, Tobias},
  Booktitle = {Proceedings of the 12th International Modelica Conference},
  Year = {2017},
  Address = {Prague, Czech Republic},
  Editor = {Kofránek, Jiří and Casella, Francesco},
  Month = may,
  Pages = {713--723},
  Doi = {10.3384/ecp17132713},
}

License

This Modelica package is free software and the use is completely at your own risk; it can be redistributed and/or modified under the terms of the BSD-3-Clause License.

Development and contribution

The master branch of the Modelica_DeviceDrivers library should work out-of-the-box when loading the library into a supporting Modelica tool. The branch contains the necessary external C libraries as pre-build binaries below folder Modelica_DeviceDrivers/Resources/Library.

If you need to build the external C libraries from the sources, clone the repository with

git clone --recursive https://github.com/modelica-3rdparty/Modelica_DeviceDrivers.git
git submodule update --init --recursive

and see Modelica_DeviceDrivers/Resources/README.md.

Main developers:

You may report any issues with using the Issues button.

Contributions in shape of Pull Requests are always welcome.

The following people have directly contributed to the implementation of the library (many more have contributed by providing feedback and suggestions):

modelica_devicedrivers's People

Contributors

adrpo avatar bernhard-thiele avatar chemeris avatar dietmarw avatar henrikt-ma avatar it-cosmos avatar manasdas17 avatar max-privato avatar sjoelund avatar tbeu avatar thorade avatar tilmanbuente avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modelica_devicedrivers's Issues

Process priority not reset

Function setProcessPriority is only called at the start of the simulation but not reset at the end of the simulation.

Also it would be nice if there would be an option to not set the process priority in Modelica_DeviceDrivers.Blocks.OperatingSystem.SynchronizeRealtime.

Github project description

I edited the description from

Free (standard conform) library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, shared memory, AD/DA converters and other devices.

to

Free library for interfacing hardware drivers to Modelica models. There is support for joysticks, keyboards, UDP, shared memory, AD/DA converters and other devices.

thus deleting the "standard conform" which is misleading and simply does not hold as long as #1669 (= first issue of #54) and #71 aren't resolved. Once they are properly fixed it could be reverted.

MDD_socketCANRead not in compliance with MLS

There is a comment @TODO Not sure whether memcpy to data is possible in external Modelica functions. Check. on function MDD_socketCANRead in MDDSocketCAN.h. According to the Modelica Language Specification (MLS) input arguments of type String map to const char* C type. If doing so the memcpy operation is no longer legal. New memory for the return buffer needs to be allocated by the ModelicaAllocateString function. See also c94ae5c for #23 and #27 where it was fixed for MDDSoftingCAN.h.

Linux support of SoftingCAN

In Softing's download center I can see a "CAN-AC PCI V5.18 Driver for Linux Kernel 3.2 (Kubuntu 12.04 LTS)". Does this mean that SoftingCAN could be ported to Linux?

Old-style icon

The package icon of Modelica_DeviceDrivers.Blocks looks old-style compared to all other icons visible in the library browser. Should the icon of Modelica.Blocks be reused here?

How to use Arduino Uno

I tried to connect arduino uno board with Openmodelica and Modelica_DeviceDrivers ,but couldn't succeed.Could you plz how to perform the communication between Openmodelica and arduino by using Modelica_DeviceDrivers package.

Fix of #10 introduced new bug on my machine

I just noticed that the changes of #10 result in error when trying to compile on my windows machine:
16>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(41): error C2485: '__declspec': nicht erkanntes erweitertes Attribut
16>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\ctype.h(41): error C2059: Syntaxfehler: '('

Reverting to the version before the fix, fixes the bug for me.
@tbeu Since I don't work so much with Windows and Visual Studio I wonder if you have any comments on that. For the moment, I'm going to revert this change.

Issues on SynchronizeRealtime

MDD_realtimeSynchronize uses static variables which is no good programming since it is not thread-safe. Therefore it would be better to implement Modelica_DeviceDrivers.Blocks.OperatingSystem.SynchronizeRealtime as an external object.

Improve JoystickInput

Linux implementation of MDD_joystickGetData uses static variables and never frees allocated memory for axis and button arrays. It should be turned into an external object.

Annotation for External Libraries and Include Files

According to the Modelica Language Specification chapter 12.9.4 the annotations for external libraries and include files should be placed on the external function declaration (and not on the Modelica function).
So instead of

encapsulated function constructor "Claim the memory"
    import Modelica_DeviceDrivers.Packaging.SerialPackager;
  input Integer bufferSize = 16 * 1024;
  output SerialPackager pkg;
  external "C" pkg = MDD_SerialPackagerConstructor(bufferSize);
  annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
             Include = "#include \"MDDSerialPackager.h\" ");
end constructor;

better have

encapsulated function constructor "Claim the memory"
  import Modelica_DeviceDrivers.Packaging.SerialPackager;
  input Integer bufferSize = 16 * 1024;
  output SerialPackager pkg;
  external "C" pkg = MDD_SerialPackagerConstructor(bufferSize)
    annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
               Include = "#include \"MDDSerialPackager.h\" ");
end constructor;

Note the missing semicolon after the external function declaration.

MDD_udpReceivingThread

Two questions on MDD_udpReceivingThread of MDDUDPSocket.h.

  1. Why are there two different functions MDD_udpReceivingThread?
  2. Is it really necessary to have DllExport on first function MDD_udpReceivingThread? It is not referenced from Modelica files.

TCP/IP support wanted?

My branch add-TCP/IP-support at tbeu/Modelica_DeviceDrivers contains a not yet final implementation of a TCP/IP socket client (for Windows).
@bernhard-thiele Can you please test and estimate if you want to have this in the library? In Incubate?

Only clocked/sampled communication

Currently the communication is cyclic only.

Proposal: This is taken from a trigger type implementation we once did for CAN and where more trigger options are available.

type trigger_type=enumeration(
  event_trig "Event",
  cyclic_trig "Cyclic",
  cyclic_event_trig "Cyclic + Event",
  initial_trig "At Start only",
  terminal_trig "At Stop only") "Use as trigger";

Improve documentation regarding 32-bit vs 64-bit pitfalls of Linux libraries

Some commercial tool are only available as 32-bit application for Linux. Also the compilation of the simulation binary is done for 32-bit. Consequently, system libraries required by some devices need to be available as 32-bit libraries in these cases. This is sometimes a difficulty for users to figure out.

Notably, the keyboard interface needs the X11 library, and it must be available as 32-bit version if compilation is done for 32-bit.

Might think of writing a guide for a specific combination of tool and linux distribution (e.g., Dymola + Ubuntu).

Inconsitency of inclusion of ModelicaUtilities.h

In the Library include files we find includes like this

#include "ModelicaUtilities.h"
#include "../src/include/CompatibilityDefs.h"

in case of MSVC. But ModelicaUtilities.h is located in same directory as CompatibilityDefs.h is. Thus ModelicaUtilities.h is not found without explicitly adding src/include to the include path. Thus I propose to get either rid of the extra src/include directory by adding all files to the main Include directory. Or alternetively the include directives should be made consistent.

Communication.SoftingCAN not supported on 64-bit machine

There is Library={"canL2"} set to the annotation of the external functions of the Communication.SoftingCAN. However, canL2.lib and canL2.dll are not available for 64-bit simulation tools where the appropriate Softing lib is named canL2_64.

x64 binary of ITI_MDDSoftingCAN.dll

Modelica_DeviceDrivers\Resources\Library\win64\ITI_MDDSoftingCAN.dll links against Debug Version of MSVC runtime (MSVCR100D.dll). Please adapt to use release version.

HTML errors

The released version v1.1 contains lots of HTML errors.
https://gist.github.com/dietmarw/c4dc5629e581702eb2d1

In addition are links to images or other packages are pointing to the wrong place (looks like the URL was typed incorrectly):

[Checking file /home/dietmarw/.workspace/gh-modelica/Modelica_DeviceDrivers/Resources/help/Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.UnpackUnsignedInteger.html]:
Not found: Modelica_DeviceDrivers.Blocks.Examples.TestSerialPackagerBitUnpack_UDP.html
[Checking file /home/dietmarw/.workspace/gh-modelica/Modelica_DeviceDrivers/Resources/help/Modelica_DeviceDrivers.UsersGuide.html]:
Not found: Modelica_DeviceDrivers.UsersGuide.Literature.html
[Checking file /home/dietmarw/.workspace/gh-modelica/Modelica_DeviceDrivers/Resources/help/Modelica_DeviceDrivers.Utilities.Icons.InternalPackage.html]:
Not found: ../Extras/Images/dlr_logo.png
[Checking file /home/dietmarw/.workspace/gh-modelica/Modelica_DeviceDrivers/Resources/help/Modelica_DeviceDrivers.Utilities.Icons.html]:
Not found: ../Extras/Images/dlr_logo.png

MDDSpaceMouse.lib

It looks like MDDSpaceMouse.lib is (and also previously was) compiled with /MD. If I am not wrong Dymola takes /MT as default. Please check and test.

TestInputSpaceMouse.c
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
   Creating library TestInputSpaceMouse.lib and object TestInputSpaceMouse.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
TestInputSpaceMouse.exe : fatal error LNK1169: one or more multiply defined symbols found
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\link.EXE"' : return code '0x491'
Stop.

Awkward I/O causality in communication examples

As written in c273fe6 I noticed that most of the communication example models are awkward due to the missing I/O causality of the communication source and sink block being both in the same model. Thus it is not defined if a source reads the data from the current or the previous sample step.

This can be solved if the source blocks get some kind of causality input (which would be the pkgIn.dummy of the corresponding sink block). Shall we do this? @bernhard-thiele Please advise if I can do it.

By the way, if I remember correctly TLC (code generation from Simulink models) has some strategy to send as early as possible and to read as late as possible.

DllExport in CompatibilityDefs.h

DllExport in CompatibilityDefs.h is always defined no matter if the project is compiled as DLL or EXE. I propose to add a new macro MDD_EXPORTS that needs to be actively set if MDD is compiled as dynamic library, i.e. MDD_EXPORTS has to be set in the cmake build script / VS project.

Different directory structure between branches

Branch release has different directory structure (with top level directory Modelica_DeviceDrivers 1.2) than branches master or dllwrapper. This is not compatible when switching branches.

I propose to also add this top level directory (available with release branch) to other branches.

Assignment of external objects not conform with MLS

Customer asked for UDP support in SimulationX. Thus I tried to figure out why SerialPackager fails in SimulationX. The reason is that the external objects, i.e. there constructors are used in assignments which is illegal according to the MLS 3.3 (rev 1) section 12.9.7: "Only the constructor may return external objects and external object can only be bound in component declarations and neither modified later nor assigned to."
Thus the current design of the SerialPackager and the Communication package is bad in two ways 😒

  1. External objects in connectors are not legal since the connect statement is equivalent to an assignment equation.
  2. Constructing the external object in when initial() is not legal at all.

Whereas SimulationX is tolerant with the first problem the second problem is a really bad design failure. I changed the construction of the external object from something like

model Packager
  Interfaces.PackageOut pkgOut;
  protected
    Integer bufferSize;
  equation
    when initial() then
      bufferSize = something;
      pkgOut.pkg = SerialPackager(bufferSize); // create external object here
    end when;
end Packager;

to

model Packager
  Interfaces.PackageOut pkgOut(pkg = SerialPackager(bufferSize));
  protected
    Integer bufferSize;
  equation
    when initial() then
      bufferSize = something;
    end when;
end Packager;

which still violates the first problem but could fix the second one. However, this now reveals the bad design of the auto propagation of the buffer size. It is not clear which external object defines the auto buffer size and which external object uses the derived buffer size.

In the need for a quick fix for the second problem I would consider to either use a fixed buffer size or refer to some global parameters like e.g. Modelica.Mechanics.MultiBody.World of the MSL holds.

@bernhard-thiele, @MartinOtter What do you think? Can we find a workaround in order to get the customer project running soon? Do you have other ideas to fix the second problem (or even the first problem to make the library really standard conform)? I am willing to contribute of course.

libraryinfo.mos

The libraryinfo.mos file says version 1.2 and MSL version 3.2. Should this be updated?

Support of big endian

Customer uses UDPSend to send data (double, float, int32) to external tool. He noticed that only little endian is supported whereas external tool expects big endian.
It would be nice if byte order layout could be chosen in UDP (and similar) blocks. Or should it go to Packager or Add/Get blocks? I can do it but would like to know where it belongs best?
@bernhard-thiele Please advice quickly since customer askes for it.

Modelica License 2 for header files

Is it right to have the header files licensed under Modelica License 2? Usually only the Modelica files of a package use Modelica License 2 whereas C source and header files use some more appropriate license like BSD3.

Release plan

Any plans to release a new version? v1.3 was released one year ago and many fixes where added since then.

I also propose to switch to semantic versioning, i.e. 1.4.0 would be a proper name according to https://github.com/mojombo/semver.

Dimension conflict in SerialPackager

I stumbled accross the following lines in the add and get functions of the SerialPackager, e.g.

    when pkgIn.trigger then
      pkgOut.dummy =
        Modelica_DeviceDrivers.Blocks.Packaging.SerialPackager.Internal.DummyFunctions.addRealAsFloat(
          pkgOut.pkg,
          u,
          pkgIn.dummy,
          byteOrder);
    end when;

addRealAsFloat takes a scalar SerialPackager as first argument and returns a scalar Real variable. However pkgOut is not a scalar PackageOut connector but of dimension nu.

What is the reason of having nu in PartialSerialPackager?

Windows compilation

Windows compilation is restricted to MSVC. It should be straight forward to relax Windows compilation to also support MinGW and Cygwin.

discrete input/output variables of connector

Apply the following patch to the master branch

 Modelica_DeviceDrivers/Blocks/Interfaces.mo | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Modelica_DeviceDrivers/Blocks/Interfaces.mo b/Modelica_DeviceDrivers/Blocks/Interfaces.mo
index 76705ef..d667751 100644
--- a/Modelica_DeviceDrivers/Blocks/Interfaces.mo
+++ b/Modelica_DeviceDrivers/Blocks/Interfaces.mo
@@ -5,7 +5,7 @@ package Interfaces
   connector PackageIn "Packager input connector"
     input Modelica_DeviceDrivers.Packaging.SerialPackager pkg;
     input Boolean trigger;
-    input Real dummy;
+    discrete input Real dummy;

     output Boolean backwardTrigger;
     output Integer userPkgBitSize;
@@ -27,7 +27,7 @@ package Interfaces
   connector PackageOut "Packager output connector"
     output Modelica_DeviceDrivers.Packaging.SerialPackager pkg;
     output Boolean trigger;
-    output Real dummy;
+    discrete output Real dummy;

     input Boolean backwardTrigger;
     input Integer userPkgBitSize;

Now Dymola 2016 raises the following translation error on Modelica_DeviceDrivers.Blocks.Examples.TestSerialPackager_UDP which I do not understand.

The following real variables are declared with the prefix discrete,
but are not assigned in a when-clause, either by an assignment or an equation:
addFloat.pkgIn.dummy
addInteger.pkgIn.dummy
addReal.pkgIn.dummy
getFloat.pkgIn.dummy
getInteger.pkgIn.dummy
getReal.pkgIn.dummy
uDPSend.pkgIn.dummy

TestSerialPackager_UDP: Initial conditions are not fully specified

Translation of Modelica_DeviceDrivers.Blocks.Examples.TestSerialPackager_UDP:

The DAE has 102 scalar unknowns and 102 scalar equations.

The initial conditions for variables of type Real are not fully specified.
Dymola has selected default initial conditions.

Assuming fixed default start value for the discrete states:
getFloat.y[1](start = 0.0)
getFloat.y[2](start = 0.0)
getReal.y[1](start = 0.0)
getReal.y[2](start = 0.0)
getReal.y[3](start = 0.0)

The initial conditions for variables of type Integer are not fully specified.
Dymola has selected default initial conditions.

Assuming fixed default start value for the discrete states:
getInteger.y[1](start = 0)

Statistics

Original Model
Number of components: 33
Variables: 137
Parameters: 31 (31 scalars)
Unknowns: 106 (112 scalars)
Equations: 47
Nontrivial: 47

Translated Model
Constants: 30 scalars
Free parameters: 18 scalars
Parameter depending: 23 scalars
Time-varying variables: 26 scalars
Alias variables: 46 scalars
Assumed default initial conditions: 6
Number of mixed real/discrete systems of equations: 0
Sizes of linear systems of equations: { }
Sizes after manipulation of the linear systems: { }
Sizes of nonlinear systems of equations: { }
Sizes after manipulation of the nonlinear systems: { }
Number of numerical Jacobians: 0

Selected continuous time states

Finished

// experiment StopTime=5 StartTime=0

WARNING: 2 warnings were issued

Finished

Should this be fixed in the Get blocks or in the example model?

MSVC build (CompatibilityDefs.h)

CompatibilityDefs.h includes winsock2.h for MSVC build. This breaks the compilation.

TestInputKeyboardKey.c
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\winsock.h(460) : see previous definition of 'AF_IPX'
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\ws2def.h(131) : warning C4005: 'AF_MAX' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\winsock.h(479) : see previous definition of 'AF_MAX'
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\ws2def.h(168) : warning C4005: 'SO_DONTLINGER' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\winsock.h(402) : see previous definition of 'SO_DONTLINGER'
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\ws2def.h(212) : error C2011: 'sockaddr' : 'struct' type redefinition
...
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\cl.EXE"' : return code '0x2'

The issue can be resolved if

  • winsock2.h is not included in CompatibilityDefs.h
  • MDDSharedMemory.h also includes Windows.h
  • MDDUDPSocket.h includes Windows.h instead of winsock2.h

I recommend to remove the whole MSVC compatibility block as it is actually not needed.

Support of SimulationX wanted?

Support of SimulationX built-in simulation requires a vendor specific annotation in case of a missing Library annotation for external functions.

This is OK:

  encapsulated function write
    import Modelica_DeviceDrivers.Communication.SharedMemory;
    input SharedMemory sm;
    input String data;
    input Integer len;
    external "C" MDD_SharedMemoryWrite(sm,data,len)
    annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
           Include = "#include \"MDDSharedMemory.h\" ",
           Library = "rt");
  end write;

But this needs to be changed from

  encapsulated function getDataSize
    import Modelica_DeviceDrivers.Communication.SharedMemory;
    input SharedMemory sm;
    output Integer length;
    external "C" length=  MDD_SharedMemoryGetDataSize(sm)
    annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
           Include = "#include \"MDDSharedMemory.h\" ");
  end getDataSize;

to either

  encapsulated function getDataSize
    import Modelica_DeviceDrivers.Communication.SharedMemory;
    input SharedMemory sm;
    output Integer length;
    external "C" length=  MDD_SharedMemoryGetDataSize(sm)
    annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
           Include = "#include \"MDDSharedMemory.h\" ",
           __iti_dll = "rt.dll");
  end getDataSize;

or

  encapsulated function getDataSize
    import Modelica_DeviceDrivers.Communication.SharedMemory;
    input SharedMemory sm;
    output Integer length;
    external "C" length=  MDD_SharedMemoryGetDataSize(sm)
    annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
           Include = "#include \"MDDSharedMemory.h\" ",
           Library = "rt");
  end getDataSize;

If wanted I can send pull request on it. Please comment.

Only clocked/sampled RandomRealSource

There actually is no need to have sampled RNG in Blocks.OperatingSystem.RandomRealSource. I propose to add a conditional external trigger port for the block. In case this trigger is off the RNG should happen in every step (which matches also the block icon). Do you agree?

CANL2_CH_STRUCT not defined in CAN Layer2 V5.17

I almost forgot this one to report: I installed CAN Layer2 V5.17 where in CANL2.H the struct CANL2_CH_STRUCT is commented out:

/*
typedef struct canl2_ch_s {
    CAN_HANDLE     ulChannelHandle;
    unsigned char  sChannelName[80];
} CANL2_CH_STRUCT;
*/

However, CANL2_CH_STRUCT is referenced by MDDSoftingCAN.h.

I propose to define and use an own struct based on the commented type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.