This documentation is out of date.
The new version of the documentation is here: https://cannylogic.com/docs |
Difference between revisions of "CANNY 5.2 duo, CAN Gateway Driver"
[unchecked revision] | [checked revision] |
(→Driver's registers) |
(→Examples) |
||
(14 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
== General Description == | == General Description == | ||
− | + | Using the CAN gateway driver you can to implement the high-speed asynchronous relaying of messages between the CAN hardware interfaces with optional filtering and altering particular CAN messages. | |
+ | The CAN gateway driver allows you to realize individual processing of incoming CAN messages by configuring up to eight selection rules (selectors). | ||
− | + | Each rule (selector) allows you to select CAN messages by the combination of following user-defined properties values: | |
+ | * CAN interface number via which the message was coming to the controller; | ||
+ | * CAN ID of incoming message (CAN gateway selector value). | ||
− | + | When some incoming CAN message hit the selector, the CAN gateway driver perform one of the following user-defined actions: | |
− | * | + | * relay the message to another CAN interface of the controller "as is", without any changes; |
− | * | + | * modify the message, and then relay the modified message to another CAN interface of the controller; |
+ | * discard the message. | ||
+ | In case of the message modification it is performed by replacing using a bitmask any bits of the original message. You can change any CAN-message field including ID, length and bits of data. | ||
− | + | For all incoming CAN message that are not hit in any selector, you can assign one of the following actions: | |
− | * | + | * relay the message to another CAN interface of the controller "as is", without any changes; |
− | + | * discard the message. | |
− | * | + | |
− | + | To use the CAN gateway driver, it is necessary to specify the possible different configurations for both CAN-interfaces of the controller. | |
+ | When the CAN gateway driver is enabled, the diagram still can use the registers of the CAN0 Driver and the CAN1 Driver for: | ||
+ | * sending any CAN messages through any of the CAN interfaces; | ||
+ | * receive CAN messages, but only those that are hit some CAN gateway driver selector, regardless of what happens with the CAN message after its selection. | ||
− | + | Moreover, you can change CAN gateway driver configuration during operation. So you can organize some sort of the dynamic mode for your CAN gateway. | |
− | + | ||
− | + | ||
+ | == Driver's registers == | ||
− | + | Below is a description of the permissible values of the CAN gate driver control registers, which allow setting the controller operation parameters for high-speed asynchronous relaying of messages between the CAN hardware interfaces. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Common registers of the CAN gateway driver. | |
− | |||
{|border="1" style="border-collapse:collapse;" align="left" width="100%" | {|border="1" style="border-collapse:collapse;" align="left" width="100%" | ||
|- align="center" valign="top" | |- align="center" valign="top" | ||
Line 64: | Line 59: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"|CAN gateway configuration register | + | |style="padding-left:0.5em;"|CAN gateway configuration update register |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 71: | Line 66: | ||
|width="70px" style="padding-left:0.5em;"|≥ 1 | |width="70px" style="padding-left:0.5em;"|≥ 1 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"|Apply the new settings of the CAN gateway driver | + | |style="padding-left:0.5em;"|Apply the new settings of the CAN gateway driver. Must be shortly set when the CAN Gateway Driver parameters need be changed during operation; |
|- valign="top" | |- valign="top" | ||
|width="70px" style="padding-left:0.5em;"|= 0 | |width="70px" style="padding-left:0.5em;"|= 0 | ||
Line 81: | Line 76: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"|CAN | + | |style="padding-left:0.5em;"|CAN Gateway Excluding Mode Enable for CANx interface |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 88: | Line 83: | ||
|width="70px" style="padding-left:0.5em;"|≥ 1 | |width="70px" style="padding-left:0.5em;"|≥ 1 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"|switch on the filtering mode of the CAN gateway for the corresponding interface: relay to the second CAN interface of the controller and transmit only CAN messages that are | + | |style="padding-left:0.5em;"|switch on the filtering mode of the CAN gateway for the corresponding interface: relay to the second CAN interface of the controller and transmit only CAN messages that are accepted by the gateway selections, the remaining messages are discarded; |
|- valign="top" | |- valign="top" | ||
|width="70px" style="padding-left:0.5em;"|= 0 | |width="70px" style="padding-left:0.5em;"|= 0 | ||
Line 113: | Line 108: | ||
|} | |} | ||
− | + | Common CAN gateway driver selection registers. | |
− | + | ||
− | + | ||
− | + | ||
{|border="1" style="border-collapse:collapse;" align="left" width="100%" | {|border="1" style="border-collapse:collapse;" align="left" width="100%" | ||
|- align="center" valign="top" | |- align="center" valign="top" | ||
− | !width="250px"| | + | !width="250px"|Registers |
− | ! | + | !Expected values |
|- valign="top" | |- valign="top" | ||
| | | | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X enable register |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 133: | Line 125: | ||
|width="70px" style="padding-left:0.5em;"|≥ 1 | |width="70px" style="padding-left:0.5em;"|≥ 1 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|enable the appropriate selection of the CAN gateway; |
|- valign="top" | |- valign="top" | ||
|width="70px" style="padding-left:0.5em;"|= 0 | |width="70px" style="padding-left:0.5em;"|= 0 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|the corresponding CAN gateway selection is disabled. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 143: | Line 135: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X linked CAN interface number register |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 150: | Line 142: | ||
|width="70px" style="padding-left:0.5em;"|= 0 | |width="70px" style="padding-left:0.5em;"|= 0 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|apply the appropriate selection to the messages coming to the controller via the CAN0 interface; |
|- valign="top" | |- valign="top" | ||
|width="70px" style="padding-left:0.5em;"|= 1 | |width="70px" style="padding-left:0.5em;"|= 1 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|apply the appropriate selection to the messages coming to the controller via the CAN1 interface. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 160: | Line 152: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN Gateway Selector X Drop Mode Enable |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 167: | Line 159: | ||
|width="70px" style="padding-left:0.5em;"|≥ 1 | |width="70px" style="padding-left:0.5em;"|≥ 1 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|discard all messages which match an enabled selection; |
|- valign="top" | |- valign="top" | ||
|width="70px" style="padding-left:0.5em;"|= 0 | |width="70px" style="padding-left:0.5em;"|= 0 | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|allow processing and automatic retransmission to another CAN interface of all messages which match an enabled selection. |
|} | |} | ||
|} | |} | ||
− | + | CAN gateway selection registers. | |
− | ''''' | + | '''''The value of the selection''''' - is a parameter which, when satisfied, selects an incoming CAN message for special processing. |
{|border="1" style="border-collapse:collapse;" align="left" width="100%" | {|border="1" style="border-collapse:collapse;" align="left" width="100%" | ||
|- align="center" valign="top" | |- align="center" valign="top" | ||
− | !width="250px"| | + | !width="250px"|Register |
− | ! | + | !Expected value |
|- valign="top" | |- valign="top" | ||
| | | | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X value, IDL |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 195: | Line 187: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|the value of the lower part of the identifier (bits 0 ... 10 of the standard format identifier or bits 0 ... 15 of the extended format identifier) of the CAN message the selection will accept. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 201: | Line 193: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X value, IDH |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 208: | Line 200: | ||
|width="70px" style="padding-left:0.5em;"|0...0x1FFF | |width="70px" style="padding-left:0.5em;"|0...0x1FFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|the value of the highest part of the identifier (bits 16 ... 28 of the extended format identifier) of the CAN message the selection will accept. |
|} | |} | ||
|} | |} | ||
− | + | The registers of the gateway driver selection masks. | |
− | ''''' | + | '''''The selection masks''''' - is a group of values whose bits define the bitwise modifications to be made when the gateway retransmits a part of the message that has been accepted by the appropriate selection. If the value of the mask bit is "0", the corresponding bit of the received message will be relayed to the other interface without changes. If the value of the mask bit is "1", the corresponding bit of the received message will be replaced by a corresponding bit from the value of the appropriate Replace Setup Register, |
{|border="1" style="border-collapse:collapse;" align="left" width="100%" | {|border="1" style="border-collapse:collapse;" align="left" width="100%" | ||
|- align="center" valign="top" | |- align="center" valign="top" | ||
− | !width="250px"| | + | !width="250px"|Register |
− | ! | + | !Expected value |
|- valign="top" | |- valign="top" | ||
| | | | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X mask setup register, IDL |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 232: | Line 224: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the value of the mask of the lower part of the CAN message identifier (bits 0 ... 10 of the standard format identifier or bits 0 ... 15 of the extended format identifier) of the corresponding selection. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 238: | Line 230: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X mask setup register, IDH |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 245: | Line 237: | ||
|width="70px" style="padding-left:0.5em;"|0...0x1FFF | |width="70px" style="padding-left:0.5em;"|0...0x1FFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the mask value of the upper part of the CAN message identifier (bits 16 ... 28 of the extended format identifier) of the appropriate selection. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 251: | Line 243: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X mask setup register, ERL |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 258: | Line 250: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|Set the mask value of the ERL register of the CAN message of the appropriate selection. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 264: | Line 256: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X mask setup register, CAN D1:D0 |
|- valign="top" | |- valign="top" | ||
|style="padding-left:0.5em;"|... | |style="padding-left:0.5em;"|... | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X mask setup register, CAN D7:D6 |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 275: | Line 267: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the value of the mask for the corresponding byte of data of the CAN message of the corresponding selection. |
|} | |} | ||
|} | |} | ||
− | + | Registers for replacing the selections of the CAN gateway driver. | |
− | ''''' | + | '''''Replacement of selection''''' - is a group of values whose bits replace the original bits in the retransmitted message that has fallen into the appropriate selection. If the value of the replacement bit is "0", the corresponding bit of the relayed message will be replaced by zero, with the replacement bit value equal to "1", the corresponding bit of the relayed message will be replaced by one. '''The replacement will only be applied to those bits whose selection mask value is "1".''' |
− | + | ||
{|border="1" style="border-collapse:collapse;" align="left" width="100%" | {|border="1" style="border-collapse:collapse;" align="left" width="100%" | ||
|- align="center" valign="top" | |- align="center" valign="top" | ||
− | !width="250px"| | + | !width="250px"|Register |
− | ! | + | !Expected value |
|- valign="top" | |- valign="top" | ||
| | | | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X replace setup register, CAN IDL |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 300: | Line 291: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the value of the replacement of the lower part of the CAN message identifier (bits 0 ... 10 of the standard format identifier or bits 0 ... 15 of the extended format identifier) of the corresponding selection. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 306: | Line 297: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X replace setup register, CAN IDH |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 313: | Line 304: | ||
|width="70px" style="padding-left:0.5em;"|0...0x1FFF | |width="70px" style="padding-left:0.5em;"|0...0x1FFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the value of the replacement of the highest part of the CAN message identifier (bits 16 ... 28 of the extended format identifier) of the corresponding selection. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 319: | Line 310: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X replace setup register, CAN ERL |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 326: | Line 317: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the replacement value of the ERL register of the CAN message of the selection being used. |
|} | |} | ||
|- valign="top" | |- valign="top" | ||
Line 332: | Line 323: | ||
{|border="0" align="left" | {|border="0" align="left" | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X replace setup register, CAN D1:D0 |
|- valign="top" | |- valign="top" | ||
|style="padding-left:0.5em;"|... | |style="padding-left:0.5em;"|... | ||
|- valign="top" | |- valign="top" | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|CAN gateway selector X replace setup register, CAN D7:D6 |
|} | |} | ||
|valign="top"| | |valign="top"| | ||
Line 343: | Line 334: | ||
|width="70px" style="padding-left:0.5em;"|0...0xFFFF | |width="70px" style="padding-left:0.5em;"|0...0xFFFF | ||
|style="padding-left:0.5em;"|= | |style="padding-left:0.5em;"|= | ||
− | |style="padding-left:0.5em;"| | + | |style="padding-left:0.5em;"|set the replacement values of the corresponding data bytes of the CAN message of the corresponding selection. |
|} | |} | ||
|} | |} | ||
<br clear="all"> | <br clear="all"> | ||
− | == | + | == Diagram of the CAN Gateway Driver operation == |
− | [[ | + | The block diagram shows the processing of CAN messages received through CAN0 interface. CAN messages received through CAN1 are processed in a similar manner. |
+ | |||
+ | [[File:14_8_2_1.png|800px]] | ||
+ | |||
+ | == Examples == | ||
+ | |||
+ | '''Example 1:''' Disable the retransmission of CAN messages with the specified identifier. | ||
+ | |||
+ | [[File:14_8_3_1.png]] | ||
+ | |||
+ | All messages, except messages with ID = 0x0123, that came from CAN0 are transmitted to CAN without any changes and are not included in the diagram. Message data with ID = 0x0123 may be available in the user diagram, but not relayed to the CAN1 interface. | ||
+ | |||
+ | All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram. | ||
+ | |||
+ | '''Example 2:''' Static Gateway: CAN message relay with data change. | ||
+ | |||
+ | [[File:14_8_3_2.png]] | ||
+ | |||
+ | All messages, except messages with ID = 0x0120, that came with CAN0 are transmitted to CAN1 without any changes and are not included in the diagram. Data messages with ID = 0x0120 can be available in the user diagram and are relayed to the CAN1 interface with the given mask and replacement selection. | ||
+ | |||
+ | All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram. | ||
+ | |||
+ | In the process of operation, the message diagrams with IDL = 0x0120 will be transmitted to CAN1 with a bit of 0 byte D0 equal to 0. | ||
+ | |||
+ | '''Example 3:''' Processing received CAN messages in a custom diagram. | ||
+ | |||
+ | [[File:14_8_3_3.png|800px]] | ||
+ | |||
+ | All messages, except messages with ID = 0x01A0, that come from the CAN0 interface are transmitted to CAN1 without any changes and are not included in the diagram. Message data with ID = 0x01A0 may be available in the user diagram, but not relayed to the CAN1 interface. | ||
+ | |||
+ | All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram. | ||
+ | |||
+ | In the course of the diagram operation, all CAN messages from the CAN0 interface with IDL = 0x01A0 will be blocked by the controller, i.e. will not be relayed to the CAN1 interface, but the data received from them will be available in the custom diagram. | ||
+ | |||
+ | Received messages with IDL = 0x01A0 are processed in the user diagram. When a message with IDL = 0x01A0 is received at the CAN1 interface, a message with IDL = 0x0208 containing static data is sent, as well as several data bytes, the value of which is calculated depending on the data received in the message IDL = 0x01A0 from CAN0. The length of the message sent to CAN1 with IDL = 0x0208 is 8 bytes. | ||
+ | |||
+ | '''Example 4:''' Dynamic gateway. | ||
+ | |||
+ | [[File:14_8_3_4.png|800px]] | ||
+ | |||
+ | For example, the data of interest to us is transmitted to CAN in ID 0x0123, in byte D1. | ||
+ | |||
+ | The mode of operation of the gateway is controlled using a clock button (GND) connected to channel No. 8 of the controller. When the controller is turned on, the selection screen 0 of the gateway D1: D0 is set to 0x0000, i.e. the incoming data is not processed by the driver, there is no change in them during retransmission. The first pressing of the control button sets the selection mask 0 of the gateway D1: D0 to work with byte D1; the next time it is pressed, the selection mask 0 of the gateway D1: D0 returns to the value 0x0000, etc. | ||
+ | |||
+ | Gateway is inactive (selection screen 0 of gateway D1: D0 is set to 0x0000). Data stream filtration is not performed, all messages that came from CAN0 are transmitted to CAN1 without changes, all messages that came from CAN1 are transmitted to CAN0 without changes, the data of both interfaces are not included in the diagram. | ||
+ | |||
+ | The gateway is in operation (selection screen 0 of the gateway D1: D0 is set to 0xFF00). | ||
+ | |||
+ | All messages, except messages with ID = 0x123, that came from CAN0 are transmitted to CAN1 without any changes and are not included in the diagram. Message data with ID = 0x123 is available in the custom diagram. In all messages with ID = 0x123, sent from CAN0, if the value of byte D1 is not equal to 0x20, when transmitting them to CAN1, the value of byte D1 is set equal to 0x10, otherwise - it is set equal to 0x20, i.e. transmitted without change. | ||
+ | |||
+ | All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram. | ||
+ | |||
+ | '''ATTENTION! Any change in the settings of the gateway (for example, selection mask registers or selection replacement registers) requires updating the driver configuration using a special register.''' | ||
<!--NOPDF--> | <!--NOPDF--> | ||
+ | |||
== See also == | == See also == | ||
[[CANNY 5.2 duo]] | [[CANNY 5.2 duo]] |
Latest revision as of 13:41, 10 December 2018
Contents
General Description
Using the CAN gateway driver you can to implement the high-speed asynchronous relaying of messages between the CAN hardware interfaces with optional filtering and altering particular CAN messages.
The CAN gateway driver allows you to realize individual processing of incoming CAN messages by configuring up to eight selection rules (selectors).
Each rule (selector) allows you to select CAN messages by the combination of following user-defined properties values:
- CAN interface number via which the message was coming to the controller;
- CAN ID of incoming message (CAN gateway selector value).
When some incoming CAN message hit the selector, the CAN gateway driver perform one of the following user-defined actions:
- relay the message to another CAN interface of the controller "as is", without any changes;
- modify the message, and then relay the modified message to another CAN interface of the controller;
- discard the message.
In case of the message modification it is performed by replacing using a bitmask any bits of the original message. You can change any CAN-message field including ID, length and bits of data.
For all incoming CAN message that are not hit in any selector, you can assign one of the following actions:
- relay the message to another CAN interface of the controller "as is", without any changes;
- discard the message.
To use the CAN gateway driver, it is necessary to specify the possible different configurations for both CAN-interfaces of the controller.
When the CAN gateway driver is enabled, the diagram still can use the registers of the CAN0 Driver and the CAN1 Driver for:
- sending any CAN messages through any of the CAN interfaces;
- receive CAN messages, but only those that are hit some CAN gateway driver selector, regardless of what happens with the CAN message after its selection.
Moreover, you can change CAN gateway driver configuration during operation. So you can organize some sort of the dynamic mode for your CAN gateway.
Driver's registers
Below is a description of the permissible values of the CAN gate driver control registers, which allow setting the controller operation parameters for high-speed asynchronous relaying of messages between the CAN hardware interfaces.
Common registers of the CAN gateway driver.
Register | Expected values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
| |||||||
|
|
Common CAN gateway driver selection registers.
Registers | Expected values | |||||||
---|---|---|---|---|---|---|---|---|
|
| |||||||
|
| |||||||
|
|
CAN gateway selection registers.
The value of the selection - is a parameter which, when satisfied, selects an incoming CAN message for special processing.
Register | Expected value | ||||
---|---|---|---|---|---|
|
| ||||
|
|
The registers of the gateway driver selection masks.
The selection masks - is a group of values whose bits define the bitwise modifications to be made when the gateway retransmits a part of the message that has been accepted by the appropriate selection. If the value of the mask bit is "0", the corresponding bit of the received message will be relayed to the other interface without changes. If the value of the mask bit is "1", the corresponding bit of the received message will be replaced by a corresponding bit from the value of the appropriate Replace Setup Register,
Register | Expected value | ||||||
---|---|---|---|---|---|---|---|
|
| ||||||
|
| ||||||
|
| ||||||
|
|
Registers for replacing the selections of the CAN gateway driver.
Replacement of selection - is a group of values whose bits replace the original bits in the retransmitted message that has fallen into the appropriate selection. If the value of the replacement bit is "0", the corresponding bit of the relayed message will be replaced by zero, with the replacement bit value equal to "1", the corresponding bit of the relayed message will be replaced by one. The replacement will only be applied to those bits whose selection mask value is "1".
Register | Expected value | ||||||
---|---|---|---|---|---|---|---|
|
| ||||||
|
| ||||||
|
| ||||||
|
|
Diagram of the CAN Gateway Driver operation
The block diagram shows the processing of CAN messages received through CAN0 interface. CAN messages received through CAN1 are processed in a similar manner.
Examples
Example 1: Disable the retransmission of CAN messages with the specified identifier.
All messages, except messages with ID = 0x0123, that came from CAN0 are transmitted to CAN without any changes and are not included in the diagram. Message data with ID = 0x0123 may be available in the user diagram, but not relayed to the CAN1 interface.
All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram.
Example 2: Static Gateway: CAN message relay with data change.
All messages, except messages with ID = 0x0120, that came with CAN0 are transmitted to CAN1 without any changes and are not included in the diagram. Data messages with ID = 0x0120 can be available in the user diagram and are relayed to the CAN1 interface with the given mask and replacement selection.
All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram.
In the process of operation, the message diagrams with IDL = 0x0120 will be transmitted to CAN1 with a bit of 0 byte D0 equal to 0.
Example 3: Processing received CAN messages in a custom diagram.
All messages, except messages with ID = 0x01A0, that come from the CAN0 interface are transmitted to CAN1 without any changes and are not included in the diagram. Message data with ID = 0x01A0 may be available in the user diagram, but not relayed to the CAN1 interface.
All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram.
In the course of the diagram operation, all CAN messages from the CAN0 interface with IDL = 0x01A0 will be blocked by the controller, i.e. will not be relayed to the CAN1 interface, but the data received from them will be available in the custom diagram.
Received messages with IDL = 0x01A0 are processed in the user diagram. When a message with IDL = 0x01A0 is received at the CAN1 interface, a message with IDL = 0x0208 containing static data is sent, as well as several data bytes, the value of which is calculated depending on the data received in the message IDL = 0x01A0 from CAN0. The length of the message sent to CAN1 with IDL = 0x0208 is 8 bytes.
Example 4: Dynamic gateway.
For example, the data of interest to us is transmitted to CAN in ID 0x0123, in byte D1.
The mode of operation of the gateway is controlled using a clock button (GND) connected to channel No. 8 of the controller. When the controller is turned on, the selection screen 0 of the gateway D1: D0 is set to 0x0000, i.e. the incoming data is not processed by the driver, there is no change in them during retransmission. The first pressing of the control button sets the selection mask 0 of the gateway D1: D0 to work with byte D1; the next time it is pressed, the selection mask 0 of the gateway D1: D0 returns to the value 0x0000, etc.
Gateway is inactive (selection screen 0 of gateway D1: D0 is set to 0x0000). Data stream filtration is not performed, all messages that came from CAN0 are transmitted to CAN1 without changes, all messages that came from CAN1 are transmitted to CAN0 without changes, the data of both interfaces are not included in the diagram.
The gateway is in operation (selection screen 0 of the gateway D1: D0 is set to 0xFF00).
All messages, except messages with ID = 0x123, that came from CAN0 are transmitted to CAN1 without any changes and are not included in the diagram. Message data with ID = 0x123 is available in the custom diagram. In all messages with ID = 0x123, sent from CAN0, if the value of byte D1 is not equal to 0x20, when transmitting them to CAN1, the value of byte D1 is set equal to 0x10, otherwise - it is set equal to 0x20, i.e. transmitted without change.
All messages coming from CAN1 are transmitted to CAN0 without changes, they are not included in the diagram.
ATTENTION! Any change in the settings of the gateway (for example, selection mask registers or selection replacement registers) requires updating the driver configuration using a special register.
See also