njh / imiev-elm-logger

Log data from Mitsubishi i-Miev cars using an ELM compatible OBD2 adaptor
MIT License
0 stars 0 forks source link

imiev CAN logging with Linux #1

Open fowi4hjte opened 1 week ago

fowi4hjte commented 1 week ago

This is how CAN logging with for example a obdlink sx cable is possible on the imiev:

sudo ldattach --debug --speed 2000000 --eightbits --noparity --onestopbit --iflag -ICRNL,INLCR,-IXOFF 30 /dev/ttyUSB0 sudo ip link set can0 type can bitrate 500000 sudo ip link set can0 up cansniffer can0 -t 0 candump can0 -f $(date +%Y%m%d-%H%M%S).log

Maybe this tool here is a upcoming gui replacement for this task: https://github.com/jakka351/GenericDiagnosticTool

njh commented 1 week ago

I think I will delete this repo because I am using WiCAN now. Using WiCAN avoids having to do CAN → Serial → Bluetooth → MQTT. Instead I can just do CAN → MQTT.

I was not using Linux native CAN support. I was using ELM based command-set with a bluetooth adapter:

Setting Up

Install

sudo apt install bluetooth pi-bluetooth bluez blueman libbluetooth-dev python3-bluetooth

Reset Bluetooth Adaptor

sudo hciconfig hci0 reset

Restart Bluetooth Service

sudo invoke-rc.d bluetooth restart

List Bluetooth Adaptors

hciconfig

Scan for Bluetooth devices

hcitool scan
bluetoothctl info 00:04:3E:5E:E0:7A

Ping Device Logical link control and adaptation protocol (L2CAP)

sudo l2ping -c 1 00:04:3E:5E:E0:7A
sudo rfcomm release rfcomm0 00:04:3E:5E:E0:7A
sudo rfcomm bind rfcomm0 00:04:3E:5E:E0:7A

rfcomm show 00:04:3E:5E:E0:7A
rfcomm0: 00:04:3E:5E:E0:7A channel 1 clean 

minicom --baud 115200 --8bit --device /dev/rfcomm0
sudo vi /etc/bluetooth/rfcomm.conf

rfcomm0 {
    # Automatically bind the device at startup
    bind yes;

    # Bluetooth address of the device
    device 00:04:3E:5E:E0:7A;

    # RFCOMM channel for the connection
    channel 1;

    # Description of the connection
    comment “OBDLink MX+";
}

ELM Commands

>AT I
ELM327 v1.4b

>AT @1
OBD SOLUTIONS LLC

>STDI
OBDLink MX+ r3.1.3

>STI
STN2255 v5.9.4

>AT RV
14.4V

# Turn on echo (for use in terminal)
ATE1

# Turn on Linefeed
ATL1 


# Turn on headers
ATH1

# Turn on spaces between hex values
ATS1

# Disable packet formatting
ATCAF0

# Set Protocol 6 - ISO 15765-4 (CAN 11/500)
ATSP6

# Get State of Charge
>AT CRA 374

>AT MA