I am using “easycan” sample code from Drive SDK (easycan_test) to open socket for CAN communication.
Easycan example uses semd_msg() to send CAN messages through Aurix:
rc = send_msg(MSG_NODE_SECU, CAN_MSG_TEGRA_A_TO_F, msg_id, 8, data);
Internally send_msg() calls sendto():
rc = sendto(sock, txMessage, msg.length+sizeof(pdu), 0, (struct sockaddr *) &remoteServAddr, sizeof (remoteServAddr));
I kept default setup/initialization code from easycan and modified the code to send 2 messages (id 0x10 and 0x20) in a loop with 20ms delay:
for (i=0; i<100; i++)
{
rc = send_msg(MSG_NODE_SECU, CAN_MSG_TEGRA_A_TO_F, 0x10, 8, data);
usleep(20000); // 20ms
rc = send_msg(MSG_NODE_SECU, CAN_MSG_TEGRA_A_TO_F, 0x20, 8, data);
usleep(20000); // 20ms
}
The code above works and I receive 100 of 0x10 and 100 of 0x20 messages using PCAN connected to CAN F bus.
However, if I reduce the first delay from 20ms to 5ms, then 0x20 messages disappear completely.
for (i=0; i<100; i++)
{
rc = send_msg(MSG_NODE_SECU, CAN_MSG_TEGRA_A_TO_F, 0x10, 8, data);
usleep(5000); // 5ms
rc = send_msg(MSG_NODE_SECU, CAN_MSG_TEGRA_A_TO_F, 0x20, 8, data);
usleep(20000); // 20ms
}
With this code (above), only 0x10 messages are received by PCAN and 0x20 messages do not show up on CAN F at all.
Is it expected behavior? Do you know where the messages disappear? i.e. during transfer over ethernet or discarded in Aurix firmware?
I also tried the same test with local Tegra CAN controller (using mttcan and SocketCAN drivers) and it works much better - it can handle all the messages even if they are sent back to back without delay.
I used original can-utils (sendcan.c) source code to open socket for SocketCAN and modified it to send messages in a loop.
The code below works fine and sends messages as fast as possible. All 0x10 and 0x20 messages are received by PCAN correctly.
for (i=0; i<100; i++)
{
frame.can_id = 0x10;
write(s, &frame, required_mtu);
// no delay.
frame.can_id = 0x20;
write(s, &frame, required_mtu);
// no delay.
}