xcpChannel unable to set bus speed (baud rate)

3 views (last 30 days)
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?

Accepted Answer

Jaskirat
Jaskirat on 19 Feb 2025
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 Comment
Johan
Johan on 24 Feb 2025
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.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!