canOpen (Function) |
Top Previous Next |
This will open a CAN port. Before the CAN functions can be used, the interface must be initialized and the baud rate must be set. A standard baud rate range is available for easy configuration. When the function has successfully returned, the messages can be transmitted (canSendMessage) and received (if a receive filter is created with canFilterCreate, canFilterCreateOnce, or canFilterCreateX). Once done with sending and receiving messages, the port can be closed with canClose.
Monitor mode is a way for the RTCU device to listen for and receive messages without interacting with the CAN network. When in monitor mode, the canSendMessage is disabled and no messages can be sent. The RTCU device does not acknowledge messages received. This means that if no other CAN device is present on the CAN network, the sender will repeat the message regularly; or if the sender is another RTCU device, that canSendMessage will return 4 (Timeout).
Note: when the CAN port is opened without having monitor enabled (and the hardware has write access, please see the technical documentation for the device), an acknowledgement is sent to the CAN network for all incoming messages as per the CAN standard.
Input: port : SINT (1/2) (default 1) The port of the CAN bus.
baud : INT (50, 62 (62.5 kbps), 100,125,250,500,1000) (default 100) Selects the desired baud rate in Kbps.
monitor : BOOL (default TRUE) Selects monitor mode.
Returns: INT
Declaration: FUNCTION canOpen : BOOL;
Example: INCLUDE rtcu.inc |