Invalid constructor signature for CAN message transmit

5 次查看(过去 30 天)
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