<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# API Reference — Performing Vehicle Forensics

## python-obd

```python
import obd
conn = obd.OBD('/dev/ttyUSB0')
conn.query(obd.commands.VIN)          # Vehicle Identification Number
conn.query(obd.commands.SPEED)        # Current speed
conn.query(obd.commands.RPM)          # Engine RPM
conn.query(obd.commands.GET_DTC)      # Diagnostic Trouble Codes
conn.query(obd.commands.FUEL_LEVEL)   # Fuel level
conn.query(obd.commands.COOLANT_TEMP) # Coolant temperature
conn.close()
```

## can-utils

```bash
# Set up CAN interface
sudo ip link set can0 type can bitrate 500000
sudo ip link set up can0

# Capture traffic
candump can0 -l -f candump.log
candump can0,7DF:7FF              # Filter OBD-II only

# Send CAN frame
cansend can0 7DF#0201050000000000  # Request PID 0x05

# Replay
canplayer -I candump.log vcan0=can0

# Virtual CAN for testing
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0
```

## cantools

```bash
cantools decode vehicle.dbc candump.log
cantools dump vehicle.dbc
cantools list vehicle.dbc
```

```python
import cantools
db = cantools.database.load_file('vehicle.dbc')
message = db.get_message_by_name('EngineData')
decoded = message.decode(b'\x00\x00\x00\x00\x00\x00\x00\x00')
```

## GPX Parsing

```python
import xml.etree.ElementTree as ET
tree = ET.parse('track.gpx')
ns = {'gpx': 'http://www.topografix.com/GPX/1/1'}
for pt in tree.findall('.//gpx:trkpt', ns):
    print(pt.get('lat'), pt.get('lon'))
```

## NMEA Sentence Format

```
$GPRMC,123456,A,4807.038,N,01131.000,E,022.4,084.4,230326,003.1,W*6A
       time   V lat      N/S lon       E/W speed course date   mag
```

| Sentence | Data |
|----------|------|
| `$GPRMC` | Time, position, speed, course, date |
| `$GPGGA` | Position, altitude, satellite count |
| `$GPGSA` | DOP and active satellites |
| `$GPGSV` | Satellites in view |
