Receiving CAN Massages with Vehicle Network Toolbox
Show older comments
canChannel1 = canChannel("Vector", "VN7610 1", 2);
candb = canDatabase("Namedbc.dbc");
Message1 = canMessage(candb,"Message1");
Message2 = canMessage(candb,"Message2");
% Start CAN Communication "receive"
start(canChannel1);
Message1 = receive(canChannel1,inf,"OutputFormat","object");
Signal1 = unpack(Message1 , 16, 16, 'LittleEndian', 'int16')
stop(canChannel1);
start(canChannel1); % this stopping and starting the canchannel is only for debug purposes
Message2 = receive(canChannel1,inf,"OutputFormat","object");
Signal2 = unpack(Message2, 0, 16, 'LittleEndian', 'int16')
stop(canChannel1);
Hello,
the matlab code above shows my testscript to get signals out of a CAN bus. I simulate the data on the CAN BUS with a tool called "BUSMASTER". With this tool i can send data in a CAN Message, which belongs to a dbc file. My hardware setup is a PEAK-System device to send CAN messages and Vector device to receive the messages from the bus.
So my problem is that, when i send more than one message at the a time, i not always get the rigth value of the signal. I dont understand how the messages can disturb each other. So here is the "MessageCount" put to "inf" to see how the value changes if i add another can message. If i add another can massage there follows to the existing one, the existing gets another wrong value in the vector.
Example: 3 Can Messages are activ and 4000 is the value i want to send -> [4000 0 0 4000 0 0 4000 0 0]
At the end i only want one value when the script is used.
Whould be very nice if someone could help me with my problem.
Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Vehicle Network Toolbox 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!