Good day,
I tried experimenting with can1 and the 250 kbit/s setting
P11 (can0) and P12(can1) were connected by two wires via DSUB9 connectors and the third connector is connected to PCAN (CAN analyzer). The ends of the wires are fitted with 2 x 120 ohms.
Message ID 0x18FF0102 being sent from can0. Can0 and can1 have no filter set, so they read everything. The PCAN analyzer generates messages 0x18FF0101 after 1000 ms
In this case, everything works:
- can0 sees message from PCAN 0x18FF0101
- can1 sees message from PCAN 0x18FF0101 and from can0 0x18FF0102
- PCAN sees message from can0 0x18FF0102
BUT when turning on the sending of another message from PCAN 0x18FF0201, PCAN sees nothing and reports Bus-Off. Can0 and can1 also do not see messages from PCAN. Bus-Off For PCAN hardware this means:
The CAN controller has entered the “Bus-Off” state because a serious and continuous error exists on the bus (255 error points have been exceeded). A possible cause can be a short circuit on the bus.
If I change the Source address for the message from PCAN 0x18FF0201, for example, from 01 to 02, that means 0x18FF0202, then everything works again. So I don’t know what the problem is. There was also a problem with message 0x18FFB203.
Code:
int main(int argc, char** argv)
{
(void)argc;
(void)argv;
dwStatus status;
std::cout << "*************************************************" << std::endl;
std::cout << "AVK_example_CAN_can0tocan1_250" << std::endl;
std::cout << "*************************************************" << std::endl;
dwSensorParams params_CAN_0{};
dwSensorParams params_CAN_1{};
params_CAN_0.protocol = "can.socket";
params_CAN_0.parameters = "device=can0";
params_CAN_1.protocol = "can.socket";
params_CAN_1.parameters = "device=can1";
dwSensorHandle_t canSensor_CAN_0;
dwContextHandle_t sdk_CAN_0 = DW_NULL_HANDLE;
dwSALHandle_t hal_CAN_0 = DW_NULL_HANDLE;
{
dwContextParameters sdkParams_CAN_0 = {};
CHECK_DW_ERROR(dwInitialize(&sdk_CAN_0, DW_VERSION, &sdkParams_CAN_0));
dwSAL_initialize(&hal_CAN_0, sdk_CAN_0);
}
status = dwSAL_createSensor(&canSensor_CAN_0, params_CAN_0, hal_CAN_0);
status = dwSensor_start(canSensor_CAN_0);
dwSensorHandle_t canSensor_CAN_1;
dwContextHandle_t sdk_CAN_1 = DW_NULL_HANDLE;
dwSALHandle_t hal_CAN_1 = DW_NULL_HANDLE;
{
dwContextParameters sdkParams_CAN_1 = {};
CHECK_DW_ERROR(dwInitialize(&sdk_CAN_1, DW_VERSION, &sdkParams_CAN_1));
dwSAL_initialize(&hal_CAN_1, sdk_CAN_1);
}
status = dwSAL_createSensor(&canSensor_CAN_1, params_CAN_1, hal_CAN_1);
status = dwSensor_start(canSensor_CAN_1);
int loop = 1;
while(loop)
{
dwCANMessage msg{};
status = dwSensorCAN_readMessage(&msg, 0, canSensor_CAN_0);
std::cout << "Status Read CAN 0: " << status << std::endl;
while(status == DW_SUCCESS)
{
std::cout << "Read CAN 1: Msg: 0x" << std::setw(8) << std::hex << std::uppercase
<< msg.id << std::endl;
status = dwSensorCAN_readMessage(&msg, 0, canSensor_CAN_0);
std::cout << "Status Read CAN 0: " << status << std::endl;
}
msg.id = 0x18FF0102;
msg.data[0] = 0xFF;
msg.size = 8;
msg.timestamp_us = 0;
status = dwSensorCAN_sendMessage(&msg, 10000, canSensor_CAN_0);
std::cout << "Status Write CAN 0: " << status << std::endl;
status = dwSensorCAN_readMessage(&msg, 0, canSensor_CAN_1);
std::cout << "Status Read CAN 1: " << status << std::endl;
while(status == DW_SUCCESS)
{
std::cout << "Read CAN 1: Msg: 0x" << std::setw(8) << std::hex << std::uppercase
<< msg.id << std::endl;
status = dwSensorCAN_readMessage(&msg, 0, canSensor_CAN_1);
std::cout << "Status Read CAN 1: " << status << std::endl;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
const auto now = std::chrono::system_clock::now();
const std::time_t t_c = std::chrono::system_clock::to_time_t(now);
std::cout << "Time: " << std::ctime(&t_c) << std::endl;
}
dwSensor_stop(canSensor_CAN_0);
dwSAL_releaseSensor(canSensor_CAN_0);
dwSensor_stop(canSensor_CAN_1);
dwSAL_releaseSensor(canSensor_CAN_1);
return 0;
}
I also tried setting quantum directly and as I tried different variants, it seems that you have an error when setting tq 16:
sudo ip link set can0 down; sudo ip link set can0 type can tq 16 prop-seg 93 phase-seg1 94 phase-seg2 62 sjw 1; sudo ip link set can0 up
Number of time quanta = 93 + 94 +62 + 1 = 250
Bit time = tq * Number of time quanta = 16 * 250 = 4000 ns
Bit rate = 1/(4000/1000000000) = 250,000 bit/s
When using the command:
ip -details -statistics link show can0
a bit rate of 200,000 bit/s is written in the console. It’s like it takes the smallest value of tq 20, but I couldn’t find a limit for it anywhere.

I also don’t know if it’s ok if I use the command
sudo ip link set can1 type can bitrate 250000; sudo ip link set can1 up
and I leave can0 in the stop state. So can1 doesn’t work. Only when I set can0 does it work.
Thank you