J1939 SPN CAN Bit Extractor & C99 Code Generator

Extract an Intel little-endian J1939 SPN from an 8-byte EEC1 example and generate a C99 mask and extraction function.

Jump to results

Inputs

Captured payload
Classic CAN 8 bytes or CAN FD 16 bytes. Spaces are optional.
DBC signals
Signal 1

Results

Estimates
Decoded signals1
SPN 190 Engine Speed
2,000 rpm
Bit map · 64 bits
B0 · FFB1 · FFB2 · FFB3 · 80B4 · 3EB5 · FFB6 · FFB7 · FF76543210 Bit 7 = 1 · unassigned 1 Bit 6 = 1 · unassigned 1 Bit 5 = 1 · unassigned 1 Bit 4 = 1 · unassigned 1 Bit 3 = 1 · unassigned 1 Bit 2 = 1 · unassigned 1 Bit 1 = 1 · unassigned 1 Bit 0 = 1 · unassigned 1 Bit 15 = 1 · unassigned 1 Bit 14 = 1 · unassigned 1 Bit 13 = 1 · unassigned 1 Bit 12 = 1 · unassigned 1 Bit 11 = 1 · unassigned 1 Bit 10 = 1 · unassigned 1 Bit 9 = 1 · unassigned 1 Bit 8 = 1 · unassigned 1 Bit 23 = 1 · unassigned 1 Bit 22 = 1 · unassigned 1 Bit 21 = 1 · unassigned 1 Bit 20 = 1 · unassigned 1 Bit 19 = 1 · unassigned 1 Bit 18 = 1 · unassigned 1 Bit 17 = 1 · unassigned 1 Bit 16 = 1 · unassigned 1 Bit 31 = 1 · SPN 190 Engine Speed 1 Bit 30 = 0 · SPN 190 Engine Speed 0 Bit 29 = 0 · SPN 190 Engine Speed 0 Bit 28 = 0 · SPN 190 Engine Speed 0 Bit 27 = 0 · SPN 190 Engine Speed 0 Bit 26 = 0 · SPN 190 Engine Speed 0 Bit 25 = 0 · SPN 190 Engine Speed 0 Bit 24 = 0 · SPN 190 Engine Speed 0 Bit 39 = 0 · SPN 190 Engine Speed 0 Bit 38 = 0 · SPN 190 Engine Speed 0 Bit 37 = 1 · SPN 190 Engine Speed 1 Bit 36 = 1 · SPN 190 Engine Speed 1 Bit 35 = 1 · SPN 190 Engine Speed 1 Bit 34 = 1 · SPN 190 Engine Speed 1 Bit 33 = 1 · SPN 190 Engine Speed 1 Bit 32 = 0 · SPN 190 Engine Speed 0 Bit 47 = 1 · unassigned 1 Bit 46 = 1 · unassigned 1 Bit 45 = 1 · unassigned 1 Bit 44 = 1 · unassigned 1 Bit 43 = 1 · unassigned 1 Bit 42 = 1 · unassigned 1 Bit 41 = 1 · unassigned 1 Bit 40 = 1 · unassigned 1 Bit 55 = 1 · unassigned 1 Bit 54 = 1 · unassigned 1 Bit 53 = 1 · unassigned 1 Bit 52 = 1 · unassigned 1 Bit 51 = 1 · unassigned 1 Bit 50 = 1 · unassigned 1 Bit 49 = 1 · unassigned 1 Bit 48 = 1 · unassigned 1 Bit 63 = 1 · unassigned 1 Bit 62 = 1 · unassigned 1 Bit 61 = 1 · unassigned 1 Bit 60 = 1 · unassigned 1 Bit 59 = 1 · unassigned 1 Bit 58 = 1 · unassigned 1 Bit 57 = 1 · unassigned 1 Bit 56 = 1 · unassigned 1

Select a bit to see its position and matching signals.

  • SPN 190 Engine Speed

An asterisk marks an overlapping bit.

Decoded signal values
SignalEncodingRaw integerRaw hexPhysical
SPN 190 Engine SpeedIntel160000x3E802,000 rpm
Generated C99 masks and functions
#include <stdint.h>

/* Pass a validated payload of at least 8 bytes. */
#define DBC_BIT(data, b) ((uint64_t)(((data)[(b) / 8] >> ((b) % 8)) & 1u))

#define DBC_1_SPN_190_ENGINE_SPEED_MASK UINT64_C(0xFFFF)
#define DBC_1_SPN_190_ENGINE_SPEED_RAW(data) (( \
    (DBC_BIT((data), 24) << 0) | \
    (DBC_BIT((data), 25) << 1) | \
    (DBC_BIT((data), 26) << 2) | \
    (DBC_BIT((data), 27) << 3) | \
    (DBC_BIT((data), 28) << 4) | \
    (DBC_BIT((data), 29) << 5) | \
    (DBC_BIT((data), 30) << 6) | \
    (DBC_BIT((data), 31) << 7) | \
    (DBC_BIT((data), 32) << 8) | \
    (DBC_BIT((data), 33) << 9) | \
    (DBC_BIT((data), 34) << 10) | \
    (DBC_BIT((data), 35) << 11) | \
    (DBC_BIT((data), 36) << 12) | \
    (DBC_BIT((data), 37) << 13) | \
    (DBC_BIT((data), 38) << 14) | \
    (DBC_BIT((data), 39) << 15) \
) & DBC_1_SPN_190_ENGINE_SPEED_MASK)
static inline double dbc_1_spn_190_engine_speed_physical(const uint8_t data[static 8]) {
    const uint64_t raw = DBC_1_SPN_190_ENGINE_SPEED_RAW(data);
    const uint64_t value = raw;
    return (double)value * (0.125) + (0.0);
}

Extract J1939 EEC1 engine speed and copy the C99 helper

The example represents the Electronic Engine Controller 1 payload, PGN 61444, with SPN 190 engine speed. It shows a synthetic classic 8-byte frame with the engine speed in one-based bytes 4 and 5. Enter payload bytes only, then use the PGN and SPN definition to choose the field layout.

Open Generated C99 masks and functions and choose Copy C code. The generated function reads the selected payload bits and can apply the configured scaling. Production code should validate the frame ID, payload length and the SPN’s special values before accepting a physical reading.

Formulas

  • Raw SPN 190 = payload[3] | (payload[4] << 8)
  • Engine speed in rpm = raw × 0.125
  • Unsigned field mask = 2^bit length − 1

Worked example

The speed bytes 80 3E combine in little-endian order to give 0x3E80, or 16,000. Multiplying by 0.125 gives 2,000 rpm. The 16-bit C99 mask is 0xFFFF.

Engineering references

Frequently asked questions

What DBC start bit corresponds to J1939 EEC1 bytes 4 and 5?

Use zero-based start bit 24, length 16 and Intel byte order for SPN 190 with its least significant byte in one-based byte 4.

Does it accept the 29-bit CAN identifier with the payload?

Enter the eight data bytes in the payload box. Use the 29-bit identifier upstream to identify the PGN and select the matching signal definitions.

How should I handle a raw unavailable or error value?

Read the valid and reserved ranges from the SPN definition and handle reserved codes before using the scaled result. The generic bit extractor reports the value implied by the configured scaling.