How to instantiate a class from a library on an S-Function

3 views (last 30 days)
Hello,
I am trying to instantiate a class from a library: mcp_can.h. The following is the code that I have placed in the "libraries" field of the S-Function builder:
  1. ifndef MATLAB_MEX_FILE
  2. include arduino.h # include "SPI.h" # include "mcp_can.h" # include "mcp_can_dfs.h" # include "Wire.h" # include "twi.h" # define CANint 2
MCP_CAN CAN0(10);
void setup()
{
pinMode(CANint, INPUT);
}
#endif
After that, the portion of the code that I have placed in the "outputs" portion executes. That code is below:
if (xD[0]==1) {
/* don't do anything for mex file generation */
# ifndef MATLAB_MEX_FILE
unsigned char stmp[8] = {50, 1, 2, 3, 4, 5, 6, 7};
CAN0.sendMsgBuf(0x200, 0, 8, stmp);
delay(.2*1000);
#endif
}
When I attempt to build this function and run it on my arduino board, I get the following errors:
C:\EcoCAR2_SVN\Controls\The Domain\The Index\Utilities\Arduino CAN Shield Simulink Support\CAN_S_Functions_rtt/CAN_Transmit_wrapper.cpp:47: undefined reference to `MCP_CAN::MCP_CAN(unsigned char)' ./CAN_Transmit_wrapper.o: In function `CAN_Transmit_Outputs_wrapper': C:\EcoCAR2_SVN\Controls\The Domain\The Index\Utilities\Arduino CAN Shield Simulink Support\CAN_S_Functions_rtt/CAN_Transmit_wrapper.cpp:86: undefined reference to `MCP_CAN::sendMsgBuf(unsigned long, unsigned char, unsigned char, unsigned char*)' make: * [MW/CAN_S_Functions.elf] Error 1
The first error is of the most concern to me and the second is a consequence of the first. Why would simulink have a problem with me instantiating the class like i do?
Any assistance would be appreciated.

Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!