lharri73 / pysimlink Goto Github PK
View Code? Open in Web Editor NEWCompile, run, and interact with Simulink models natively in Python. https://lharri73.github.io/PySimlink/
License: GNU General Public License v3.0
Compile, run, and interact with Simulink models natively in Python. https://lharri73.github.io/PySimlink/
License: GNU General Public License v3.0
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:
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
This broke in the 1.2.0 release
Trying to run a model, while following each of the steps as laid out in the documentation, results in an error listed as, "ModuleNotFoundError: No module named 'fd_interface_c'" (where fd is the name of my model).
log:
-- Configuring incomplete, errors occurred!
CMake Error at CMakeLists.txt:2 (project):
Running
'nmake' '-?'
failed with:
no such file or directory
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage.
ode14x includes cmath. pysimlink interprets this as a model which does not exist.
Add to exclusion in model_ref_compiler.py:56
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
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)
If constant blocks aren't appearing in block parameters, change this setting so they are tunable in the c api. Can be added to docs.
model_paths.py:138 will be emitted if multitasking is enabled OR if Classic Call Interface
is not checked and/or (?) Single output/update function
is not checked.
It's not required if matlogging is disabled (also not present and causes a compiler error). It is required when logging is enabled because we have to stop logging, otherwise there's a memory leak.
force_rebuild
should clear the extracted file's contents and extract again
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.
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.
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
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.
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.