13.07.2015 Views

VCI - Virtual CAN Interface - Ixxat

VCI - Virtual CAN Interface - Ixxat

VCI - Virtual CAN Interface - Ixxat

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Accessing the busAfter a message channel has been opened, it must first be initialized. This is donewith the function canChannelInitialize. The function expects as input parametersthe size of the receive and transmit buffers in number of <strong>CAN</strong> messages and thethreshold values for the receive or transmit event.The memory reserved for the receive and transmit buffers comes from a limitedsystem memory pool. The individual buffers of a message channel should thereforenot contain more than approx. 2000 messages.The receive event of a channel is triggered when the receive buffer contains atleast the number of messages specified in wRxThreshold. The transmit event istriggered when the transmit buffer has at least sufficient space for the number ofmessages specified in wTxThreshold.If the channel has been created, it can be enabled or disabled with the functioncanChannelActivate. The channel is enabled when the function is called with thevalue TRUE in the parameter fEnable. The channel is disabled by calling the functionwith the value FALSE in the parameter fEnable. A channel is disabled afteropening as the default setting.Messages are only received by the <strong>CAN</strong> controller or sent to it if the channel isactive. In addition, the <strong>CAN</strong> controller must be started, otherwise no messagetransfer takes place between the <strong>CAN</strong> bus and the channel. The message filter ofthe <strong>CAN</strong> controller also has an influence on the received messages. More informationon this is given in section 3.1.2.A message channel is closed with the function canChannelClose. The functionshould always be called when a channel is no longer needed.3.1.3.1 Reception of <strong>CAN</strong> messagesThe simplest way of reading received messages from the receive buffer is to callthe function canChannelReadMessage. If there are no messages available in thereceive buffer, the function waits until either a new message is received or thewaiting time specified in the parameter dwMsTimeout has expired. Every messagehas a associated message type (data, info, error, status, timer-overrun). (see§5.2.5 <strong>CAN</strong>MSGINFO)The function canChannelPeekMessage also reads the next message from the receivebuffer. In contrast to canChannelReadMessage, however, the function doesnot wait for a new message but returns immediately to the calling program witha corresponding error code if no message is available in the receive buffer.It is possible to wait for a new receive message or the occurrence of the receiveevent with the function canChannelWaitRxEvent. The receive event is triggeredwhen the receive buffer contains at least the number of messages specified inwRxThreshold when canChannelInitialize is called.The following code fragment shows a possible use of the functions canChannel-WaitRxEvent and canChannelPeekMessage.22Copyright IXXAT Automation GmbH C-API Programming Manual, Version 1.5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!