What Causes Queue Overflow with NI-CAN? Hardware: Industrial Communications>>CAN
Problem: I have an NI-CAN error indicating queue overflow. What does this mean and how can I correct it? Solution: NI-CAN uses read and write queues to buffer information. When a device writes a message to the bus, the message is stored in the read queue for NI-CAN to retrieve. When the software executes a read operation, it reads information from this queue. Thus, the device might be putting information into the read queue, and the software program might be taking information out of the read queue at the same time. A similar situation takes place with the write queue. Anytime you execute a write operation from NI-CAN, the board tries to put the message on the bus. Remember with NI-CAN that only one message can be on the bus at any given time. The message with the lowest arbitration ID has the highest priority. The other messages are stored in the write queue until they have the lowest arbitration ID and get control of the bus. If you get a queue overflow, this indicates that you have exceeded the size limit(s) of the read and/or the write queue. The queues have been allocated 150 bytes if you are using Network Objects or 170 bytes if you are using CAN objects. For more information on the queue length, please see the KB 1YD93QRM (linked, below). In the software program, you declare your queue size in frames. There are two basic ways to cause a queue overflow for both the read and write queue. Consider the case where you assign your read queue length to be 10 frames. If the device puts 1 frame into the queue at a time, but the software does not remove items from the queue, then eventually you will get a queue overflow error when the device tries to put the 11th frame in the queue. The problem happens here because the software program is not removing frames from the queue. When you define a queue length in CAN, you are specifying the maximum number of frames that can be in the queue at any one time. (The queue may have fewer items, if the items are removed from the queue faster than they are added.) If the software does not remove items from the queue at or faster then the device puts them in the queue then the queue will overflow. In the next situation, consider the case where you assign a read queue length of 20 frames. Assume that each frame is 10 bytes and that you are using Network Objects. Also, assume that the write queue length is 0, so that you have 150 bytes for the read queue. The device puts 15 frames in the queue (that are not being removed from the queue), when the device adds a 16th frame, you will receive an error. The frame is still within the defined limit, but you have exceeded the size of the queue length. The queue has been allocated 150 bytes, and you have exceeded this limit, so you will get an error. These errors can be handled by optimizing the speed that you are using for writing and reading on your CAN card. For further information please reference KB 2VIGB3WH (linked below). Related Links: KnowledgeBase 1YD93QRM: How Large Can I Make the Read and Write Queues for NI-CAN? KnowledgeBase 2VIGB3WH: Optimizing Speed For CAN I/O Attachments:
Report Date: 06/22/2000 Last Updated: 12/28/2006 Document ID: 1YL9E1RM |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
