REXGEN 2REXGEN 2 IMU GNSSREXGEN AirREXGEN ProDeveloper
REXGEN XML examples: route CAN traffic and signals between buses
Make the logger forward every frame from CAN 0 to CAN 1. You can also decode two signals on CAN 0 and send them on CAN 1 in a message of your own.
Before you start
A gateway needs two CAN channels. These examples run on REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air and REXGEN Pro, not on REXGEN 1. Both files run CAN 0 and CAN 1 at 500 kbit/s. They are in the Rexgen_XML_Examples repository on GitHub and validate against the schema.
To load a file with REXDESK, see REXGEN XML configuration: how it fits together. To change the bit rate of either bus, edit CANBusSpeed in its CANINTERFACE. The interface with UID 1 is CAN 0 and the one with UID 2 is CAN 1.
Route all traffic from CAN 0 to CAN 1
Gateway_CAN0_to_CAN1.xml uses four blocks:
- CAN interface UID 1 on CAN 0 and CAN interface UID 2 on CAN 1.
- Input message UID 3 on interface 1. Its identifiers run from 0 to 4294967295, so it takes every frame.
- Output message UID 4 on interface 2. Its
InputMessageUIDis 3, so it sends every frame that message 3 receives.
<CANMESSAGE UID="4">
<MessageIdentStart>0</MessageIdentStart>
<MessageIdentEnd>4294967295</MessageIdentEnd>
<Direction>OutputPeriodic</Direction>
<DLC>8</DLC>
<IsExtended>false</IsExtended>
<InterfaceUID>2</InterfaceUID>
<Period>100</Period>
<TriggeringMessageUniqueID>0</TriggeringMessageUniqueID>
<DefaultHex>0000000000000000</DefaultHex>
<CANFD_Option>NORMAL_CAN</CANFD_Option>
<InputMessageUID>3</InputMessageUID>
<Name/>
<isJ1939>false</isJ1939>
<J1939Source>0</J1939Source>
<J1939Destination>0</J1939Destination>
<Downsampling>0</Downsampling>
<Delay>0</Delay>
<NextOutputMessageID>0</NextOutputMessageID>
</CANMESSAGE>
To forward only part of the traffic, narrow MessageIdentStart and MessageIdentEnd on input message 3.
The file is Gateway_CAN0_to_CAN1.xml in the GATEWAY_CAN0_to_CAN1 folder.
Route selected signals from CAN 0 to CAN 1
Gateway_CAN0_CAN1_Signal.xml does not forward all traffic. It reads two signals on CAN 0 and packs them into one new message on CAN 1, sent every 100 ms.
| Signal | Read from (CAN 0) | Written to (CAN 1) |
|---|---|---|
| Signal1, 16 bits, unsigned | Identifier 1056 (420 hex), bits 0 to 15 | Identifier 123 (7B hex), bits 0 to 15 |
| Signal2, 8 bits, unsigned | Identifier 1536 (600 hex), bits 16 to 23 | Identifier 123 (7B hex), bits 16 to 23 |
Each signal needs three blocks:
- An input message for its source frame
- A
MESSAGEsignal that decodes the value - A
COMMONsignal that writes the value into output message 3
This is the chain for Signal2:
<CANMESSAGE UID="5">
<MessageIdentStart>1536</MessageIdentStart>
<MessageIdentEnd>1536</MessageIdentEnd>
<Direction>Input</Direction>
<DLC>8</DLC>
<IsExtended>false</IsExtended>
<InterfaceUID>1</InterfaceUID>
<Period>0</Period>
<TriggeringMessageUniqueID>0</TriggeringMessageUniqueID>
<DefaultHex>0000000000000000</DefaultHex>
<CANFD_Option>NORMAL_CAN</CANFD_Option>
<InputMessageUID>0</InputMessageUID>
<Name>Log All</Name>
<isJ1939>false</isJ1939>
<J1939Source>0</J1939Source>
<J1939Destination>0</J1939Destination>
<Downsampling>0</Downsampling>
<Delay>0</Delay>
<NextOutputMessageID>0</NextOutputMessageID>
</CANMESSAGE>
<CANSIGNAL UID="7">
<InputType>MESSAGE</InputType>
<InputUID>5</InputUID>
<MessageUID>5</MessageUID>
<StartBit>16</StartBit>
<BitCount>8</BitCount>
<Endian>INTEL</Endian>
<DefaultValue>0</DefaultValue>
<ParA>1</ParA>
<ParB>0</ParB>
<SignalType>UNSIGNED</SignalType>
<Name>Signal2</Name>
</CANSIGNAL>
<CANSIGNAL UID="9">
<InputType>COMMON</InputType>
<InputUID>7</InputUID>
<MessageUID>3</MessageUID>
<StartBit>16</StartBit>
<BitCount>8</BitCount>
<Endian>INTEL</Endian>
<DefaultValue>0</DefaultValue>
<ParA>1</ParA>
<ParB>0</ParB>
<SignalType>UNSIGNED</SignalType>
<Name>Signal2</Name>
</CANSIGNAL>
To route your own signals, change the input identifiers. Then set StartBit and BitCount on each MESSAGE signal to where the value sits in its source frame. On each COMMON signal, set them to where the value goes in the new message. Set ParA and ParB to rescale a value on the way. The file is Gateway_CAN0_CAN1_Signal.xml in the GATEWAY_CAN0_Signal_to_CAN1 folder.
Where to go next
Products in this guide
Still stuck?
Our engineers answer support questions on every Influx Technology product.