Invalid constructor signature for CAN message transmit

조회 수: 5 (최근 30일)
mehul kumar uttamchand
mehul kumar uttamchand 2023년 2월 22일
답변: Aishwarya Shukla 2023년 3월 3일
Hello community,
I am trying to connect a PEAK USB system with matlab and send CAN messages to my hardware using MATLAB/SIMULINK environment. I have created a database for CAN messages called colibri_aktor. I generate a message and transmit from matlab but an error turns up. The example code and the error are attached below.
Any help is appreciated.
db=canDatabase('Colibri_Aktor.dbc')
messsage=canMessage(db,"nmt_start")
canch=canChannel("PEAK-System","PCAN_USBBUS1","ProtocolMode","CAN")
start(canch)
transmit(canch,message)
error message
Error using message
Invalid constructor signature.
Error in untitled (line 5)
transmit(canch,message)

답변 (1개)

Aishwarya Shukla
Aishwarya Shukla 2023년 3월 3일
Hi @mehul,
It looks like there's a typo in your code. The variable messsage is misspelled and should be message. That's why MATLAB is throwing an error when you try to transmit it.
Try changing the second line of your code from this:
messsage=canMessage(db,"nmt_start")
To this:
message=canMessage(db,"nmt_start")
Also, make sure that the message "nmt_start" is defined in your Colibri_Aktor.dbc database. If it's not defined, MATLAB will not be able to create a canMessage object from it.

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by