xcpChannel unable to set bus speed (baud rate)

3 次查看(过去 30 天)
I can't find a propper way to set the busspeed when using xcpChannel function. The bus speed is defined in the a2l object that I pass to the function but it still sets the default bus speed (500 kbit/s). When creating a canChannel object I can set the bus speed with the function configBussSpeed() but this can't be used on a xcpChannel object.
The only way I could set the bus speed was to set a break point in the underlying function and call the configBusSpeed function in debug mode.
I have tested with Vector, Kvaser and PCAN usb dongles. Same result, i.e. default bus speed is set.
Is this a bug, since the bus speed is clearly defined in the A2L object? Or how do I set the bus speed in a propper way?

采纳的回答

Jaskirat
Jaskirat 2025-2-19
Hello @Johan!
There does not seem to be a direct way to use the “configBusSpeed” function with an xcpChannel object. A workaround would be to create a CAN channel and configure the bus speed before establishing the connection on XCP over CAN.
% Step 1: Create a CAN channel
% Replace 'VendorName', 'Device', and 'ChannelNumber' with your specific parameters.
canChannelObj = canChannel('VendorName', 'Device', ChannelNumber);
% Step 2: Configure the bus speed
% Set the desired bus speed in kbit/s, e.g., 250 kbit/s.
configBusSpeed(canChannelObj, 250000);
% Step 3: Create an XCP channel using the configured CAN channel
% Load your A2L file
a2lObj = xcpA2L('path_to_your_file.a2l');
% Create the XCP channel
xcpChannelObj = xcpChannel(a2lObj, canChannelObj);
% Step 4: Connect to the XCP server
connect(xcpChannelObj);
Hope this helps!
  1 个评论
Johan
Johan 2025-2-24
Thank you for a workaround. It would be helpful if the baudrate coud be set automatically with the information fetched from the A2L file and stored in the a2lobject in the future.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Motion Planning 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by