Coder Social home page Coder Social logo

lharri73 / pysimlink Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 4.0 3.83 MB

Compile, run, and interact with Simulink models natively in Python. https://lharri73.github.io/PySimlink/

License: GNU General Public License v3.0

Python 56.50% C++ 43.50%
code-generation simulink-model metaprogramming python

pysimlink's People

Contributors

lharri73 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

pysimlink's Issues

The slprj folder is not included in the zip folder

Hi,

I have generated code to my Simulink model as in your description. Although a slprj folder is generated, it is not included in the zip folder. The structure looks like this:

  • slprj
  • [my_model]_grt_rtw
  • [zip-folder]
    --- [a]
    ------ [my_model]_grt_rtw
    --- [b]
    ------ extern
    ------ rtw
    ------ simulink

When I add the slprj folder to the zip folder, it doesn't work either, because for example rtwtypes is not included in the slprj folder.
Do you know a solution how to make the project structure compliant with pysimlink?

Kind regards

math header causes crash

ode14x includes cmath. pysimlink interprets this as a model which does not exist.

Add to exclusion in model_ref_compiler.py:56

Failed to compile model with enums and nested bus objects

I have problems compiling a model that contains enums and nested bus objects. It seems that the struct_parser.py doesn't support this. When I try to implement some exceptions for these types the model compiles but it crashes when I read out the model (e.g. with get_block_param()).

I have attached a model that contains the things to reproduce the error.
Model.zip

Cannot run test compile

I am unable to compile any model on Windows. It looks like it fails to run the test compile. Output below. I can compile on linux in a docker container, but have tried two different windows machines with VS 2017 and 2019 with the desktop C++ packages installed and it won't compile. I've played with paths extensively, trying 32 and 64 bit compiler versions.

Help please!

-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - broken
-- Configuring incomplete, errors occurred!
CMake Error at C:/Users/hj397/AppData/Local/Programs/Python/Python311/Lib/site-packages/cmake/data/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: 'C:/Users/hj397/AppData/Local/Programs/Python/Python311/Lib/site-packages/__pycache__/pysimlink/simple_compile_test/build/CMakeFiles/CMakeScratch/TryCompile-ox8ssx'

Run Build Command(s): C:/Users/hj397/AppData/Local/Programs/Python/Python311/Lib/site-packages/cmake/data/bin/cmake.exe -E env VERBOSE=1 nmake -f Makefile /nologo cmTC_3facb\fast
	"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\nmake.exe"  -f CMakeFiles\cmTC_3facb.dir\build.make /nologo -L                  CMakeFiles\cmTC_3facb.dir\build
Building C object CMakeFiles/cmTC_3facb.dir/testCCompiler.c.obj
	C:\Users\hj397\AppData\Local\Programs\Python\Python311\Lib\site-packages\cmake\data\bin\cmake.exe -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_3facb.dir\testCCompiler.c.obj.d --working-dir=C:\Users\hj397\AppData\Local\Programs\Python\Python311\Lib\site-packages\__pycache__\pysimlink\simple_compile_test\build\CMakeFiles\CMakeScratch\TryCompile-ox8ssx --filter-prefix="Note: including file: " -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\cl.exe @C:\Users\hj397\AppData\Local\Temp\nmA978.tmp
testCCompiler.c
Linking C executable cmTC_3facb.exe
	C:\Users\hj397\AppData\Local\Programs\Python\Python311\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_3facb.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx86\x86\link.exe /nologo @CMakeFiles\cmTC_3facb.dir\objects1.rsp @C:\Users\hj397\AppData\Local\Temp\nmA9C7.tmp
Visual Studio Incremental Link with embedded manifests
Create CMakeFiles\cmTC_3facb.dir/manifest.rc
Create empty: CMakeFiles\cmTC_3facb.dir/embed.manifest
RC Pass 1:
rc /fo CMakeFiles\cmTC_3facb.dir/manifest.res CMakeFiles\cmTC_3facb.dir/manifest.rc
RC Pass 1: command "rc /fo CMakeFiles\cmTC_3facb.dir/manifest.res CMakeFiles\cmTC_3facb.dir/manifest.rc" failed (exit code 0) with the following output:
no such file or directoryNMAKE : fatal error U1077: 'C:\Users\hj397\AppData\Local\Programs\Python\Python311\Lib\site-packages\cmake\data\bin\cmake.exe' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\nmake.exe"' : return code '0x2'
Stop.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

Another way to force a signal to generate

Under code interface, add signal to code mappings, provide an identifier, then set storage class to 'ExportedGlobal'. Should show up in signal map. I assume this causes it to coalesce into a real signal.

msvcrt.locking permission denied

Trying to compile a model on a Window 10 machine using Python 3.12.2 but the following error gets thrown:

File "C:\temp\.venv\Lib\site-packages\pysimlink\lib\model.py", line 130, in _unlock
rv = msvcrt.locking(f.fileno(), msvcrt.LK_UNLCK, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied

Commenting out line 71 self._lock() and 83 self._unlock() in model.py fixes the issue.

Incomplete documentation on data i/o and states

I cannot figure out from the documentation how to supply signal data to root level inports and log data from root level outports prior to each step.

I also cannot tell how to save and restore model states.

Can you please provide documentation and/or an example on these critical features?

Thanks,
Dan

Failed to load compiled model

I try to load a test model into pysimlink. I do a simple:

model = Model("testmodel", "./testmodel.zip", generator='MinGW Makefiles')

After compile step I get an error loading the generated module:

(_venv) D:\Python\pySimlink>python main.py
Compiling ... done
Traceback (most recent call last):
File "D:\Python\pySimlink\main.py", line 14, in
model = Model("testmodel", "./testmodel.zip", generator='MinGW Makefiles')
File "D:\Python\pySimlink_venv\lib\site-packages\pysimlink\lib\model.py", line 92, in init
self.module = importlib.import_module(self.model_paths.module_name)
File "C:\Program Files\Python39\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 565, in module_from_spec
File "", line 1173, in create_module
File "", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing testmodel_interface_c: Das angegebene Modul wurde nicht gefunden.<

I set up a virtual environment in Python 3.9.9 with just the requirements needed for pysimlink. I also had to comment out the two lines for locking / unlocking as described in #17 .

The file "D:\Python\pySimlink\__pycache__\pysimlink\testmodel\build\out\library\testmodel_interface_c.cp39-win_amd64.pyd" is generated and is located in the given folder.

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.