GeneralDeveloper

REXGEN OEM: read and write data through the data pipes

Updated

Read live data from the REXGEN OEM logger on its Linux platform and send CAN and CAN FD frames. You do both through its data pipes.

How the data pipes work

The REXGEN embedded platform inside the logger records the CAN buses, the IMU (accelerometer and gyroscope), the analogue inputs and the digital inputs. A Linux service, rexgen_data.service, makes that data available as pipes under /var/run/rexgen/. You read and write them like ordinary files, from the shell or from your own application.

REXGEN OEM data pipes
Pipe Direction Data
/var/run/rexgen/can0/rx to can3/rx Read Frames received on CAN 0 to CAN 3
/var/run/rexgen/can0/tx to can3/tx Write Frames to send on CAN 0 to CAN 3
/var/run/rexgen/acc/rx Read Accelerometer
/var/run/rexgen/gyro/rx Read Gyroscope
/var/run/rexgen/adc/rx Read Analogue inputs
/var/run/rexgen/dig/rx Read Digital inputs

Start and stop the data service with:

systemctl start rexgen_data.service
systemctl stop rexgen_data.service

Demo applications that use the data pipes are in /home/root/rexusb/examples on the device.

Read CAN and CAN FD data

Read a bus with cat or less on its rx pipe:

cat /var/run/rexgen/can0/rx
cat /var/run/rexgen/can1/rx
cat /var/run/rexgen/can2/rx
cat /var/run/rexgen/can3/rx

Each line is one frame, with these fields:

  • A timestamp in brackets
  • The channel
  • The identifier in hex
  • The data length in square brackets
  • The data bytes in hex
(1698509051)  can0  200  [8]  FF FF 7F FF 7F FF 88 00
(1698509127)  can0  231  [7]  01 52 64 00 04 00 80
(1698510079)  can0  201  [8]  00 00 40 00 00 00 FF FF

Send CAN frames

Write a frame to a bus with echo on its tx pipe. This example sends identifier 130 with eight data bytes on CAN 0:

echo "(0) can0 130 [8] 01 02 03 04 05 06 07 08" > /var/run/rexgen/can0/tx

For CAN 1 to CAN 3, write to that channel's pipe and name the same channel in the frame, for example can1 to /var/run/rexgen/can1/tx.

Send CAN FD frames

Add [F] before the identifier to send a CAN FD frame. This example sends identifier 7B3 with 16 data bytes on CAN 0:

echo "(0) can0 [F] 7B3 [16] 01 02 03 04 05 06 07 08 88 99 88 77 66 55 44 33" > /var/run/rexgen/can0/tx

Use the other channels' tx pipes in the same way.

Read the IMU

cat /var/run/rexgen/acc/rx
cat /var/run/rexgen/gyro/rx

Each line carries a timestamp, the axis and the value:

(264397353) Y -0.018056
(264397353) Z -0.980880
(264397675) X 0.240584

The gyroscope pipe uses the same form:

(283906287) X 3.010000
(283906287) Y 2.625000

Read the analogue and digital inputs

cat /var/run/rexgen/adc/rx
cat /var/run/rexgen/dig/rx

Each analogue line carries a timestamp, the input number and the value:

(2261881788) 0 0.007500
(2261881958) 2 0.000000
(2261882196) 1 0.000000
(2261882196) 3 11.542601

In this example, input 3 reads about 11.5. This fits an analogue input connected to the power supply.

Read GNSS data

GNSS data does not use a pipe. Start it with:

/opt/influx/gnssdata_start.sh

The NMEA sentences then arrive on the serial port ttymxc1. Read them with:

cat /dev/ttymxc1
$GPGSA,A,1,,,,,,,,,,,,,,,*32
$GPGGA,,,,,,0,,,,,,,,*66
$GPRMC,,V,,,,,,,,,,N*53

Empty fields like these mean the receiver has no fix yet.

Next: REXGEN OEM: the rexgen command reference.

Still stuck?

Our engineers answer support questions on every Influx Technology product.