100%
cansult cansult view
Description

Imported from GitHub: irudoy/cansult · commit 7e1b39f · license MIT

Description

Nissan Consult (14pin) to CAN adapter

README

Nissan Consult (14pin) to CAN adapter

This project aims to translate the Nissan Consult protocol to CAN bus. It is based on the STM32F103 microcontroller and custom-made board. The adapter is both powered and communicates with the ECU through the 14-pin Consult connector.

CAN bus

Baud rate

500 Kbit/s

Frames payload

IDDLCByte 0Byte 1Byte 2Byte 3Byte 4Byte 5Byte 6Byte 7
0x6668BATTERY_VOLTAGECOOLANT_TEMPIGNITION_TIMINGLEFT_O2TPSAAC_VALVELEFT_AF_ALPHALEFT_AF_ALPHA_SELFLEARN
0x6678VEHICLE_SPEEDTACH_MSBTACH_LSBINJ_TIME_MSBINJ_TIME_LSBLEFT_MAF_MSBLEFT_MAF_LSB
0x6688BIT_1BIT_2DEVICE_VOLTAGEFirst DTC CodeHeartbeat

Data conversion (from Nissan Consult ECU register table)

CAN IDByteParameterFormulaUnits
0x6660Battery Voltageraw × 0.08V
0x6661Coolant Tempraw - 50°C
0x6662Ignition Timing110 - rawdeg BTDC
0x6663Left O2 Sensorraw × 10mV
0x6664TPSraw × 20mV
0x6665AAC Valveraw / 2%
0x6666Left AF Alpharaw%
0x6667Left AF Alpha Selflearnraw%
0x6670Vehicle Speedraw × 2km/h
0x6671-2Tachometer (RPM)(MSB×256 + LSB) × 12.5rpm
0x6673-4Injection Time(MSB×256 + LSB) / 100ms
0x6675-6Left MAF(MSB×256 + LSB) × 5mV
0x6680Digital Bit Register 1see bit tableflags
0x6681Digital Bit Register 2see bit tableflags
0x6682Device Voltageraw × 0.08V
0x6686First DTC Coderawcode
0x6687Heartbeatcounter

Source: docs/Generic_Nissan_ECU_Sensor_or_Data_register_table_Ver_2.pdf

Diagnostics — primary (0x665)

Sent at 1 Hz. Bytes 1-3 are per-second rates (saturating at 255), bytes 4-6 are monotonic uint8_t counters that wrap. Byte 7 is a freshness indicator. FE+NE framing/noise rate isn't in this frame — derive it from the uart_fe and uart_ne u16 counters in 0x66B by diffing successive samples.

ByteContentNotes
0parser.state0=STARTUP, 1=INIT, 2=POST_INIT, 3=WAITING, 4=IDLE, 5=STREAMING
1ORE/sUART overrun rate, saturating u8
2implausible/sStream frames rejected by range check (see consult_parser_validate_stream)
3CAN TX fail/sCAN mailbox-full / TX-fail rate
4dma_restart_countDMA recovery events (monotonic u8)
5watchdog_timeout_count500ms streaming watchdog fires (monotonic u8)
6reconnect_countSTARTUP-state re-entries after first boot (monotonic u8)
7(ms_since_last_good_frame) >> 2In 4ms units, saturates at ≈1020ms

Diagnostics — extended (0x66B)

Sent at 1 Hz. Full-width counters and device state.

ByteContentNotes
0-1uart_fe_countFraming errors, u16 big-endian (monotonic)
2-3uart_ne_countNoise errors, u16 big-endian (monotonic)
4-5mcu_temp_c10Internal MCU temp, signed int16 big-endian, °C × 10
6can_recover_countBus-off / RESET / ERROR software recoveries (monotonic u8)
7mode_bit << 7 | hcan.StateBit 7 = 1 if ADAPTER mode, bits 0-6 = HAL CAN state (≤5)

Debug UART stream (0x669, 0x66A)

Raw UART bytes streamed as CAN frames. Off by default, toggled via CAN command.

IDDirectionDLCContent
0x669ECU → cansult (RX)1-8Raw bytes received from ECU
0x66Acansult → ECU (TX)1-8Raw bytes sent to ECU

Adapter mode command (0x66D)

Send to cansult to switch between normal streaming and BT pass-through. In ADAPTER mode the MCU releases PA9 (USART1_TX) to high-Z, powers the BC417 Bluetooth module via PA8, pauses the parser/watchdog/CAN stream, and lets the PC talk directly to the ECU over BT. 0x665 data and 0x66B diag keep ticking so the host sees the mode change.

Byte 0Action
0x00Exit ADAPTER, return to STREAM
0x01Enter ADAPTER (BT pass-through)
0x02Toggle

Debug command (0x66F)

Send to cansult to control debug stream:

Byte 0Action
0x00Disable debug stream
0x01Enable debug stream
0x02Toggle debug stream

Build & Flash

All commands run from firmware/. Toolchain paths (STM32CubeIDE, ST-Link GDB server) are pinned in the Makefile.

make build        # Headless CubeIDE build
make test         # Host unit tests (Unity, 28 tests)
make flash        # Build + flash via ST-Link SWD
make reset        # Hardware reset via ST-Link

Debug

make ocd-server   # OpenOCD GDB server on :3333
make ocd-status   # Reset, run 3s, halt, dump parser/DMA state
make ocd-dump     # Full state snapshot via GDB script
make gdb-read EXPRS="parser.state dmaRxReadPos"
make gdb-exec  SCRIPT=scripts/dump.gdb

CAN tools (requires python-can + PCAN)

make can-monitor          # Live monitor, all cansult frames
make can-diag             # 0x665 + 0x66B diagnostics only
make can-capture          # Atomic N-second capture (CAN_DURATION=3)
make can-capture-diag     # Atomic capture: diagnostics only
make can-capture-debug    # Enable 0x669/0x66A debug stream + capture
make can-debug-on/off     # Toggle raw UART debug stream (0x66F)
make can-adapter-on/off   # Toggle BT pass-through ADAPTER mode (0x66D)

Hardware

  • STM32F103TBU6 — generates the 153.52 kHz Consult CLK on PB3 via TIM2_CH2 PWM
  • MCP2562 — CAN transceiver
Comments
Sign in to comment

No comments yet. Be the first to ask about this board.