Code Monkey home page Code Monkey logo

Comments (14)

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

This is true. But unfortunately there is no way (I know of) to encode that information into an annotation (i.e., link library "canL2_64" if compiling to a 64bit binary, otherwise take "canL2").

So I don't see any decent way to fix this.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

The idea is to build a proper static lib that already links to official canL2.lib or canL2_64.lib. This is what I did here where I named this new lib canL2_. Linking to canL2.lib or canL2_64.lib is then no longer needed for the simulation code just use canL2_.lib.
This step requires spliting MDDSoftingCAN.h to a real header file and a new source file MDDSoftingCAN.c that then will be compiled as canL2_.lib.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

Wait! It is pretty simple to solve.

  • Remove all canL2 Library annotations from the Mo files.
  • In MDDSoftingCAN.h add the following MSVC link pragmas
#if defined(_WIN64)
#pragma comment(lib, "canL2_64.lib")
#else
#pragma comment(lib, "canL2.lib")
#endif

Please test.

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

Good idea. Currently, I just have no access to the hardware to test it. Will test it as soon as I have again accesss to it.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

This works for me (in MDDSoftingCAN.h):

#if defined(_MSC_VER)
    #include <windows.h>
#if defined(_WIN64)
    #pragma comment(linker, "/DEFAULTLIB:\"..\\thirdParty\\softing\\Win64\\canL2_64.lib\"")
#else
    #pragma comment(linker, "/DEFAULTLIB:\"..\\thirdParty\\softing\\Win32\\canL2.lib\"")
#endif
#endif /* _MSC_VER */

Not sure if SoftingCAN is also supported by Linux and GCC.

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

OK. Then it should be fine.

There is no support from SoftingCAN for recent Linux kernels. Hence, having a Windows only solution is perfectly fine in this case.

I'll integrate it.

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

@tbeu Could you please check if the SoftingCAN support is now working for SimulationX?

I added a DLL named ITI_ModelicaDeviceDriversSoftingCAN.dll that hopefully works with SimulationX.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024
  1. I noticed that 32-bit binaries ITI_ModelicaDeviceDrivers.dll and ITI_ModelicaDeviceDriversSoftingCAN.dll link against Debug version of MSVC runtime. 64-bit is OK though.
  2. It misses MDDUtil.dll.

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

Don't understand why MDDUtil.dll is missed. It is only used in the SocketCAN driver, i.e., only relevant for Linux. I just linked MDDUtil into the ITI_* libraries although I have doubts that this solves the issue, but we can try.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

No, it is the Library name, that is explicitly set.

encapsulated function destructor "Destroy object, free resources"
import Modelica_DeviceDrivers.Communication.SocketCAN;
input SocketCAN socketCAN;

  external "C" MDD_socketCANDestructor(socketCAN)
  annotation (IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
              Include="#include \"MDDSocketCAN.h\"",
              Library={"MDDUtil"});
end destructor;

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

Hm. The SocketCAN functions are only supported for Linux anyway. So even if we would create an "MDDUtil.dll" it wouldn't work to execute it under Windows.

So, is this already a problem while loading the library into SimulationX or is it only a problem when trying to simulate SocketCAN examples?

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

Argh! I run the SocketCAN instead of SoftingCAN example. Sorry.

Yes, SoftingCAN works for me. You can revert c30a9d3. And you should link against Release MSVCR.

from modelica_devicedrivers.

bernhard-thiele avatar bernhard-thiele commented on August 29, 2024

OK. Removed MDDUtil from dependencies of ITI_* libraries.
So far I used the target MinSizeRel that cmake creates when generating a VS project for compiling the libs. I now used the Release target. Hope that links against the correct release libs.

from modelica_devicedrivers.

tbeu avatar tbeu commented on August 29, 2024

Thanks. You can close this issue and continue in #14.

from modelica_devicedrivers.

Related Issues (20)

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.