Is it possible to send CAN messages out of a callback function?

1 回表示 (過去 30 日間)
Roger Köhler
Roger Köhler 2016 年 12 月 8 日
Hello,
I have following problem: I would like to send CAN messages out of a callback function. This callback function is called by an timerobject. Everytime when the callback function is executed it should send the CAN message.
I coded:
canch = canChannel('PEAK-System', 'PCAN_USBBUS1');
configBusSpeed(canch, 1000000)
start(canch)
canch.Database = canDatabase('\\psf\Home\Desktop\02 CAN DBC\CAN4.dbc');
message = canMessage (canch.Database,'IPSS_RX_1_1ms');
transmitPeriodic(canch,message, 'On', 0.01);
T= timer('ExecutionMode','fixedrate','Period',0.2,...
'TimerFcn',@TEST_timer_callback_fcn,'StopFcn','disp(''Timer has stopped'')');
start(T)
Callback function:
function TEST_timer_callback_fcn(src,event)
message.Signals.In_ti= 39;
The CAN Channel starts - but the message is not send.
Can somebody help?

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by