Recent comments on posts in the blog:

Hi Qing,

please, next time post your issues to Github. I’m not sure that your problem has anything to do with ert_linux, since you write that you use GRT, which is something different. Also note that if the computations performed in one period take longer time that the sampling period, your model will never run in real time.

HTH
-Michal

Comment by wsh Tue Apr 30 09:09:30 2019
Hi, I want to run a Simulink real-time capable model on Linux with an RT-preempt patch in hard real time. The RT Linux is done, and I tested it with a simple model, it worked fine. But When I use a more complex one, 10s simulation needs to run 56s on Linux( the model is real-time capable, and I choose GRT). I have found the problem was in one simulation step some parts are repeated for serval times. What might be wrong by this, is this problem caused by the parameter settings for the code generation? Please Help Me. Thanks a lot.
Comment by Qing Mon Apr 29 09:58:37 2019
@Sriram I’ve moved the project to GitHub. Please, post other comments/issues there. Unfortunately, I don’t have Matlab 2017b (or similar newer version) at hand, so I cannot fix the problem you have. One thing that might help is that I see C++ linker to be used in your log. I’ve never test the target with C++ so this might be a problem. If you find a good solution, please send a pull request to GitHub.
Comment by wsh Mon Jan 14 15:52:13 2019
I was able to build the model by adding ert_main.c to MODULES inside the model .mk file generated by the template makefile. I am using R2017b and I think this is an issue with the template makefile.
Comment by Sriram Fri Jan 11 20:05:47 2019

Hi, With regards to the previous error I am not able to build even the example model “cantransmit_ert.slx” model that is included in the socketcan-simulink git tree and I get the same “undefined reference to main” error.

These are the steps I apply before I build this example model: a. Build all the s-functions. b. add both ert_linux and socketcan-simulink to the path by executing the setup script. c. Ensure the make command, Template makefile and the system target file are set correctly according to your instructions. (haven’t changed this since this is a example model). d. Hit Ctrl+B.

I see that ‘ert_main.c’ gets generated but I get the following error even with the demo model: (I have verified that Embedded Coder/C-compiler is setup correctly because I am able to build demo models using ert.tlc)

Building cantransmit_ert: /usr/local/MATLAB/R2017b/bin/glnxa64/gmake -f cantransmit_ert.mk OPT_OPTS=”-D_BSD_SOURCE -O2 -ggdb -Wall” ISPROTECTINGMODEL=NOTPROTECTING GENERATE_ASAP2=0 OPTS=”-DON_TARGET_WAIT_FOR_START=0”

gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “can_datatype_ground.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “cantransmit_ert_data.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “rtGetInf.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “rtGetNaN.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “rt_nonfinite.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DON_TARGET_WAIT_FOR_START=0 -DEXT_MODE -DGLNXA64 -DMODEL=cantransmit_ert -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/cantransmit_ert_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/coder/rtiostream/src/utils -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “cantransmit_ert.c” g++ -o ../cantransmit_ert can_datatype_ground.o cantransmit_ert.o cantransmit_ert_data.o ext_svr.o ext_work.o rtGetInf.o rtGetNaN.o rt_nonfinite.o rtiostream_interface.o rtiostream_tcpip.o rtiostream_utils.o updown.o -lrt -lpthread -lm /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain’ collect2: error: ld returned 1 exit status gmake: *** [../cantransmit_ert] Error 1

Comment by sriram Thu Jan 10 20:38:13 2019

Simulink does not care whether the underlying can interface is virtual or not. So yes, it is supported.

And regarding your compile error. For some reason, it cannot find the main() function. Just look whether main() was generated by Simulink. If yes, the comile/link command has to be fixed somehow. If not, the code generation templates have to be fixed.

Comment by wsh Thu Dec 20 10:17:12 2018
Hi, Do you have support for Virtual CAN vcan channels from SocketCAN in this Simulink Target? It looks like you support 3 CAN channels, but, don’t seem to support virtual channels for standalone simulation on the host.
Comment by Sriram Fri Dec 14 04:05:29 2018

Hi, My eventual goal is to test my control logic using a standalone executable deployed on a Linux target so that I can send/receive CAN commands/response to/from the executable. I am hoping that your library will allow me to both send/receive on the same Linux target(Ubuntu) without needing an linux embedded target like RPi but I am open to it if no other option is available.

At the moment, I am just testing sending a single raw CAN message using a virtual CAN channel and trying to receive the same CAN Message back. I do not have a separate target at the moment and I am just intending to run this executable standalone on the Linux Ubuntu box, but, I am getting an error message with the build as follows.

TLC code generation complete.

.

Processing Template Makefile: /fig/home/sriramnarayanan/ert_linux/ert_linux/ert_linux/ert_linux.tmf

test_cantransmit_example.mk which is generated from /fig/home/sriramnarayanan/ert_linux/ert_linux/ert_linux/ert_linux.tmf is up to date

Building test_cantransmit_example: /usr/local/MATLAB/R2017b/bin/glnxa64/gmake -f test_cantransmit_example.mk OPT_OPTS=”-D_BSD_SOURCE -O2 -ggdb -Wall” ISPROTECTINGMODEL=NOTPROTECTING GENERATE_ASAP2=0

gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DMODEL=test_cantransmit_example -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/test_cantransmit_example_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “can_datatype_ground.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DMODEL=test_cantransmit_example -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/test_cantransmit_example_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “test_cantransmit_example_data.c” gcc -c -std=c99 -pedantic -fwrapv -fPIC -D_BSD_SOURCE -O2 -ggdb -Wall -DMODEL=test_cantransmit_example -DNUMST=1 -DNCSTATES=0 -DUNIX -DMAT_FILE=0 -DINTEGER_CODE=0 -DONESTEPFCN=1 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=0 -DMT=0 -I. -I.. -I/usr/local/MATLAB/R2017b/extern/include -I/usr/local/MATLAB/R2017b/simulink/include -I/usr/local/MATLAB/R2017b/rtw/c/src -I/usr/local/MATLAB/R2017b/rtw/c/src/ext_mode/common -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks -I/fig/home/sriramnarayanan/socketcan_simulink/socketcan-simulink/blocks/test_cantransmit_example_ert_linux -I/usr/local/MATLAB/R2017b/toolbox/shared/can/src/scanutil “test_cantransmit_example.c” g++ -o ../test_cantransmit_example can_datatype_ground.o test_cantransmit_example.o test_cantransmit_example_data.o -lrt -lpthread -lm /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function _start': (.text+0x20): undefined reference tomain’ collect2: error: ld returned 1 exit status gmake: *** [../test_cantransmit_example] Error 1

Comment by Sriram Fri Dec 14 03:05:09 2018

Hi, My eventual goal is to test my control logic using a standalone executable deployed on a Linux target so that I can send/receive CAN commands/response to/from the executable. I am hoping that your library will allow me to both send/receive on the same Linux target(Ubuntu) without needing an linux embedded target like RPi but I am open to it if no other option is available.

At the moment, I am just testing sending a single raw CAN message using a virtual CAN channel and trying to receive the same CAN Message back. I do not have a separate target at the moment and I am just intending to run this executable standalone on the Linux Ubuntu box so that

Comment by Sriram Narayanan Fri Dec 14 02:53:26 2018
The generating Linux applications from Simulink is very important in the field of the embedded system. The given explanation is very nicely described in this blog.
Comment by error code 0xc004f074 Fri Nov 9 18:06:43 2018