REXGEN 2REXGEN 2 IMU GNSSREXGEN AirREXGEN ProDeveloper

REXGEN XML examples: route CAN traffic and signals between buses

Updated

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:

  1. CAN interface UID 1 on CAN 0 and CAN interface UID 2 on CAN 1.
  2. Input message UID 3 on interface 1. Its identifiers run from 0 to 4294967295, so it takes every frame.
  3. Output message UID 4 on interface 2. Its InputMessageUID is 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.

Gateway_CAN0_to_CAN1.xml, block by block REXGEN XML · GATEWAY EXAMPLE Gateway_CAN0_to_CAN1.xml, block by block CANINTERFACE the receiving port CANMESSAGE Input CANMESSAGE OutputPeriodic CANINTERFACE the sending port InterfaceUID InputMessageUID InterfaceUID UID 1 CAN 0, 500 kbit/s UID 3 Log All IDs 0 to 4294967295 takes every frame UID 4 InputMessageUID 3 sends what message 3 receives Period 100 ms UID 2 CAN 1, 500 kbit/s Each arrow is a link by UID, made by the field printed above it. Narrow the identifier range on message 3 to forward only part of the traffic. Whether forwarded frames go out as they arrive or at most every 100 ms is not stated. Needs two CAN channels: REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air or REXGEN Pro.

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 gateway: what goes where
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 MESSAGE signal that decodes the value
  • A COMMON signal 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>
Gateway_CAN0_CAN1_Signal.xml, block by block REXGEN XML · SIGNAL GATEWAY EXAMPLE Gateway_CAN0_CAN1_Signal.xml, block by block CANINTERFACE CAN 0 CANMESSAGE Input CANSIGNAL MESSAGE: decodes CANSIGNAL COMMON: writes CANMESSAGE OutputPeriodic CANINTERFACE CAN 1 InterfaceUID InputUID, MessageUID InputUID MessageUID InterfaceUID UID 1 CAN 0 500 kbit/s UID 3 ID 123 7B hex every 100 ms UID 2 CAN 1 UID 4 ID 1056, 420 hex UID 6 Signal1 bits 0 to 15 UID 8 Signal1 bits 0 to 15 UID 5 ID 1536, 600 hex UID 7 Signal2 bits 16 to 23 UID 9 Signal2 bits 16 to 23 Each arrow is a link by UID, made by the field printed above its column of arrows. Both signals are unsigned, little-endian (INTEL), with ParA 1 and ParB 0, so the values arrive unscaled. Only these two values cross to CAN 1; no other traffic is forwarded. Needs two CAN channels: REXGEN 2, REXGEN 2 IMU GNSS, REXGEN Air or REXGEN Pro.

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

REXGEN 2

Evidence data logger

View REXGEN 2 Ask an engineer

REXGEN 2 IMU GNSS

Motion & location data logging

View REXGEN 2 IMU GNSS Ask an engineer

REXGEN Air

CAN to cloud

View REXGEN Air Ask an engineer

REXGEN Pro

Edge data platform

View REXGEN Pro Ask an engineer

Still stuck?

Our engineers answer support questions on every Influx Technology product.