I have a question about communicating with an external CAN device. I'm working on a PC application to transfer data over the Komodo CAN Duo Interface. The bus is configured to run at 1 MHz and I’m starting this project with 16KB of data. When that is successful, the data blocks will be increased to megabytes of data.
With the current architecture, data is split into 32-byte "packets" plus five bytes of header information. This packet structure is then split into 8-byte CAN packets for transfer via the Komodo interface. Each of the 37-byte packets is acknowledged with a 2-byte ACK message from the receiver. The five 8-byte CAN packets are not ACK’d individually. I am using the Komodo Software API.
Here’s a summary of what I’m doing:
The known issues and fixes:
I can send the first 12 37-byte packets successfully and receive an acknowledgement. However:
The “work around” that I am using:
The improvements I’m looking for:
Thanks for your question! As implied in your statement, the issues you observed are due to buffer overflow. The solution we have for you is relatively simple. To better understand how the solution works, we will first go over the mechanics of latency settings, asynchronous messages, and what affects the data buffer.
Setting a small latency can increase the responsiveness of the read function. Please note, there is a fixed cost to processing each individual buffer that is independent of buffer size. Here are the trade-offs to consider:
The Komodo km_latency function sets the capture latency to the specified number of milliseconds. For example, if latency_ms is set to “1”, then the latency is 1ms.
The capture latency effectively splits up the total amount of buffering into smaller individual buffers (sub-buffers). After one of these individual buffers is filled, the read function returns.
In other words, if the latency_ms parameter value in the km_latency function is small, then the sub-buffers size is small. If the latency_ms parameter value in the km_latency function is big, then the sub-buffers size is big.
The latency setting is distinctly different from the timeout setting. Latency should be set to a value that is less than the timeout.
There is buffering within the Komodo DLL, on a per-device basis, to help capture asynchronous messages. Here is a case of a Komodo interface receiving CAN messages asynchronously:
The Komodo interface can be configured as an active CAN node, or as a passive CAN monitor. A CAN channel can receive messages asynchronously with respect to the host PC software. Between calls to the Komodo API, these messages must be buffered somewhere in memory. This buffering is accomplished by the operating systems of the PC host. The buffer is limited in size; when the buffer is full, bytes will be dropped.
An overflow occurs when the Komodo interface receives asynchronous messages faster than the rate at which they are processed: the receive link becomes "saturated". This condition can also affect synchronous communication with the Komodo interface.
There are two ways to relieve the receive saturation problem:
Based on your request and setup, we recommend using the API command km_can_write with your script. This function acts as a wrapper for the asynchronous submit and collect functions.
packet, num_bytes, data);
km_can_async_collect(komodo, KM_TIMEOUT_INFINITE,
arbitration_count);
How this works:
Additional resources that you may find helpful include the following:
We hope this answers your question. If you need more information, you can contact us and we’ll go over your requirements. You can also request a demo that applies to your application.