Recent comments on posts in the blog:
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 to
main’
collect2: error: ld returned 1 exit status
gmake: *** [../cantransmit_ert] Error 1
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.
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 to
main’
collect2: error: ld returned 1 exit status
gmake: *** [../test_cantransmit_example] Error 1
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
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