Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility function to retrieve MAC address #255

Merged

Conversation

tbeu
Copy link
Collaborator

@tbeu tbeu commented Aug 29, 2018

Tested with Cygwin, MinGW, MSVC and GCC on Linux.

As mentioned in #244 (comment) I needed to split the utility functions in separate header files to avoid linker errors,

TODO: Add libIPHlpApi.a to the Linux libraries

@tbeu tbeu added this to the v1.6.0 milestone Aug 29, 2018
@tbeu tbeu mentioned this pull request Aug 29, 2018
4 tasks
Copy link
Collaborator

@bernhard-thiele bernhard-thiele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I could only test it using Windows. Works with Dymola (MSVC and MinGW), doesn't work with OMC. However, since it works with MinGW I don't really understand why it fails with OMC.

@bernhard-thiele bernhard-thiele merged commit 930dbe6 into modelica-3rdparty:master Aug 31, 2018
@tbeu
Copy link
Collaborator Author

tbeu commented Aug 31, 2018

Does it fail to build or to simulate with OMC on Win?

@tbeu tbeu deleted the add-mac-address-support branch August 31, 2018 09:46
@bernhard-thiele
Copy link
Collaborator

The build fails. I get errors like

In file included from C:/OMDev/tools/msys/mingw64/x86_64-w64-mingw32/include/mprapi.h:10:0,
                 from C:/OMDev/tools/msys/mingw64/x86_64-w64-mingw32/include/iprtrmib.h:9,
                 from C:/OMDev/tools/msys/mingw64/x86_64-w64-mingw32/include/IPHlpApi.h:17,
                 from D:/ModelicaLibs/Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/MDDUtilitiesMAC.h:20,
                 from Testme_includes.h:4,
                 from Testme_functions.c:6:
C:/OMDev/tools/msys/mingw64/x86_64-w64-mingw32/include/ras.h:440:24: error: expected declaration specifiers or '...' before '*' token
   typedef VOID (WINAPI *RASDIALFUNC)(UINT,RASCONNSTATE,DWORD);

This can be avoided by adding a #define VOID void into the header. In that case my example model

model Testme
  String s;
equation
when sample(0.1,0.1) then
  s = Modelica_DeviceDrivers.Utilities.Functions.getMACAddress();
  Modelica.Utilities.Streams.print(s);
end when;
end Testme;

compiles (though there are some linker issues):

C:/OMDev/tools/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .rsrc merge failure: duplicate leaf: type: 18 (MANIFEST) name: 2 lang: 409
C:/OMDev/tools/msys/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .rsrc merge failure: differing directory versions

However, the simulation process crashes immediately.

@tbeu
Copy link
Collaborator Author

tbeu commented Aug 31, 2018

Hm, we have #define VOID void in CompatibilityDefs.h (which gets included anyway), but only for MSVC.

tbeu added a commit that referenced this pull request Aug 31, 2018
@tbeu
Copy link
Collaborator Author

tbeu commented Aug 31, 2018

f579ab6 fixes one redefinition warning.

I am also about to mark Modelica_DeviceDrivers.Utilities.Functions.getMACAddress as pure function, since normally you will not change physical address of network adapter while M_DD simulation runs. OK to change?

@bernhard-thiele
Copy link
Collaborator

Do you mean to change it by using the Modelica pure prefix or some annotation? If it is the keyword pure, shall it be the MLS 3.3 pure or MLS 3.4 (which would be a backwards compatibility issue)?

@tbeu
Copy link
Collaborator Author

tbeu commented Aug 31, 2018

No, I simply want to remove the Impure annotation.

@bernhard-thiele
Copy link
Collaborator

Sure, makes sense.

tbeu added a commit to tbeu/Modelica_DeviceDrivers that referenced this pull request Sep 1, 2018
tbeu added a commit that referenced this pull request Sep 2, 2018
tbeu added a commit that referenced this pull request Sep 2, 2018
tbeu added a commit that referenced this pull request Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants