Recent comments on posts in the blog:

@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
I have no clue. I haven’t bought the adapter.
Comment by wsh Fri Mar 23 12:58:19 2018

This is a great article, and it is exactly what I was looking for.

Does the ATX Reset Adapter (www.berkprod.com/Product_Web_Pages/atx_reset_adapter.aspx) also keep the PS_ON signal tied to the ground so that the power supply is always on?

Comment by Anthony Tue Mar 20 20:01:17 2018