mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-12 05:44:14 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd34ccfe28 | ||
|
|
59bd6b8837 | ||
|
|
7ccae06bce | ||
|
|
f91df07d3f | ||
|
|
53c4b90ffc | ||
|
|
0829b0a767 | ||
|
|
9a143c5ab2 | ||
|
|
1e8098c140 | ||
|
|
b5a88f5700 | ||
|
|
65e1342e41 | ||
|
|
7ada2abca0 | ||
|
|
9278fad15c | ||
|
|
0aa41e348e | ||
|
|
64a6e9776c | ||
|
|
56b2945de4 | ||
|
|
b686ca87d3 | ||
|
|
1b3b260b4d | ||
|
|
25d43fe15e | ||
|
|
cbc73e55a2 | ||
|
|
9b31da0985 | ||
|
|
3f9059fea8 | ||
|
|
99c81d291f | ||
|
|
530b637d27 | ||
|
|
52e55eb244 | ||
|
|
ec36bc3a39 | ||
|
|
98797fb24e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -34,3 +34,6 @@ selfdrive/visiond/visiond
|
||||
/src/
|
||||
|
||||
one
|
||||
openpilot
|
||||
xx
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ script:
|
||||
tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pyflakes $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")'
|
||||
- docker run
|
||||
tmppilot /bin/sh -c 'cd /tmp/openpilot/ && pylint $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda"); exit $(($? & 3))'
|
||||
- docker run tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover common'
|
||||
- docker run tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/can'
|
||||
- docker run tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/boardd'
|
||||
- docker run tmppilot /bin/sh -c 'cd /tmp/openpilot/ && make -C cereal && python -m unittest discover selfdrive/controls'
|
||||
- docker run tmppilot /bin/sh -c 'cd /tmp/openpilot/ && python -m unittest discover selfdrive/loggerd'
|
||||
- docker run
|
||||
-v "$(pwd)"/selfdrive/test/tests/plant/out:/tmp/openpilot/selfdrive/test/tests/plant/out
|
||||
tmppilot /bin/sh -c 'cd /tmp/openpilot/selfdrive/test/tests/plant && OPTEST=1 ./test_longitudinal.py'
|
||||
|
||||
@@ -10,9 +10,22 @@ Most open source development activity is coordinated through our [Discord](https
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* Fork [our repositories](https://github.com/commaai) on GitHub
|
||||
|
||||
## Testing
|
||||
|
||||
### Local Testing
|
||||
|
||||
You can test your changes on your machine by running `run_docker_tests.sh`. This will run some automated tests in docker against your code.
|
||||
|
||||
### Automated Testing
|
||||
|
||||
All PRs are automatically checked by travis. Check out `.travis.yml` for what travis runs. Any new tests sould be added to travis.
|
||||
|
||||
### Code Style and Linting
|
||||
|
||||
Code is automatically check for style by travis as part of the automated tests. You can also run these yourself by running `check_code_quality.sh`.
|
||||
|
||||
## Car Ports (openpilot)
|
||||
|
||||
We've released a [Model Port guide](https://medium.com/@comma_ai/openpilot-port-guide-for-toyota-models-e5467f4b5fe6) for porting to Toyota/Lexus models.
|
||||
|
||||
If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://medium.com/@comma_ai/how-to-write-a-car-port-for-openpilot-7ce0785eda84). You might also be eligible for a bounty. See our bounties at [comma.ai/bounties.html](https://comma.ai/bounties.html)
|
||||
|
||||
|
||||
@@ -2,17 +2,15 @@ FROM ubuntu:16.04
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
autoconf \
|
||||
build-essential \
|
||||
clang \
|
||||
vim \
|
||||
screen \
|
||||
wget \
|
||||
bzip2 \
|
||||
git \
|
||||
libglib2.0-0 \
|
||||
libtool \
|
||||
python-pip \
|
||||
capnproto \
|
||||
libcapnp-dev \
|
||||
libzmq5-dev \
|
||||
libffi-dev \
|
||||
libusb-1.0-0 \
|
||||
@@ -21,6 +19,9 @@ RUN apt-get update && apt-get install -y \
|
||||
ocl-icd-opencl-dev \
|
||||
opencl-headers
|
||||
|
||||
COPY phonelibs/install_capnp.sh /tmp/install_capnp.sh
|
||||
RUN /tmp/install_capnp.sh
|
||||
|
||||
RUN pip install --upgrade pip==18.0
|
||||
RUN pip install numpy==1.11.2 scipy==0.18.1 matplotlib==2.1.2
|
||||
|
||||
|
||||
23
README.md
23
README.md
@@ -76,7 +76,7 @@ Supported Cars
|
||||
| Honda | Civic Sedan/Coupe 2019 | Honda Sensing | Yes | Stock | 0mph | 2mph | Bosch |
|
||||
| Honda | Civic Hatchback 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch |
|
||||
| Honda | CR-V 2015-16 | Touring | Yes | Yes | 25mph<sup>1</sup>| 12mph | Nidec |
|
||||
| Honda | CR-V 2017-18 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch |
|
||||
| Honda | CR-V 2017-19 | Honda Sensing | Yes | Stock | 0mph | 12mph | Bosch |
|
||||
| Honda | CR-V Hybrid 2019 | All | Yes | Stock | 0mph | 12mph | Bosch |
|
||||
| Honda | Odyssey 2017-19 | Honda Sensing | Yes | Yes | 25mph<sup>1</sup>| 0mph | Inverted Nidec |
|
||||
| Honda | Passport 2019 | All | Yes | Yes | 25mph<sup>1</sup>| 12mph | Inverted Nidec |
|
||||
@@ -92,10 +92,11 @@ Supported Cars
|
||||
| Kia | Sorento 2018 | All | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
|
||||
| Kia | Stinger 2018 | SCC + LKAS | Yes | Stock | 0mph | 0mph | Custom<sup>6</sup>|
|
||||
| Lexus | RX Hybrid 2016-19 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
| Subaru | Impreza 2019 | EyeSight | Yes | Stock | 0mph | 0mph | Subaru |
|
||||
| Toyota | Avalon 2016 | TSS-P | Yes | Yes<sup>2</sup>| 20mph<sup>1</sup>| 0mph | Toyota |
|
||||
| Toyota | Camry 2018<sup>4</sup> | All | Yes | Stock | 0mph<sup>5</sup> | 0mph | Toyota |
|
||||
| Toyota | C-HR 2017-18<sup>4</sup> | All | Yes | Stock | 0mph | 0mph | Toyota |
|
||||
| Toyota | Corolla 2017-18 | All | Yes | Yes<sup>2</sup>| 20mph<sup>1</sup>| 0mph | Toyota |
|
||||
| Toyota | Corolla Hatchback 2019 | All | Yes | Yes | 0mph | 0mph | Toyota |
|
||||
| Toyota | Highlander 2017-18 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
| Toyota | Highlander Hybrid 2018 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
| Toyota | Prius 2016 | TSS-P | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
@@ -103,15 +104,16 @@ Supported Cars
|
||||
| Toyota | Prius Prime 2017-19 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
| Toyota | Rav4 2016 | TSS-P | Yes | Yes<sup>2</sup>| 20mph<sup>1</sup>| 0mph | Toyota |
|
||||
| Toyota | Rav4 2017-18 | All | Yes | Yes<sup>2</sup>| 20mph<sup>1</sup>| 0mph | Toyota |
|
||||
| Toyota | Rav4 2019 | All | Yes | Yes | 0mph | 0mph | Toyota |
|
||||
| Toyota | Rav4 Hybrid 2017-18 | All | Yes | Yes<sup>2</sup>| 0mph | 0mph | Toyota |
|
||||
|
||||
<sup>1</sup>[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma.ai](https://comma.ai)***
|
||||
<sup>2</sup>When disconnecting the Driver Support Unit (DSU), otherwise longitudinal control is stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota)
|
||||
<sup>3</sup>[GM installation guide](https://zoneos.com/volt/).
|
||||
<sup>4</sup>It needs an extra 120Ohm resistor ([pic1](https://i.imgur.com/CmdKtTP.jpg), [pic2](https://i.imgur.com/s2etUo6.jpg)) on bus 3 and giraffe switches set to 01X1 (11X1 for stock LKAS), where X depends on if you have the [comma power](https://comma.ai/shop/products/power/).
|
||||
<sup>5</sup>28mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
|
||||
<sup>6</sup>Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed for the 2019 Sante Fe; pinout may differ for other Hyundais.
|
||||
<sup>7</sup>Community built Giraffe, find more information [here](https://zoneos.com/shop/).
|
||||
<sup>1</sup>[Comma Pedal](https://community.comma.ai/wiki/index.php/Comma_Pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. Here is how to [build a Comma Pedal](https://medium.com/@jfrux/comma-pedal-building-with-macrofab-6328bea791e8). ***NOTE: The Comma Pedal is not officially supported by [comma.ai](https://comma.ai)***
|
||||
<sup>2</sup>When disconnecting the Driver Support Unit (DSU), otherwise longitudinal control is stock ACC. For DSU locations, see [Toyota Wiki page](https://community.comma.ai/wiki/index.php/Toyota)
|
||||
<sup>3</sup>[GM installation guide](https://zoneos.com/volt/).
|
||||
<sup>4</sup>It needs an extra 120Ohm resistor ([pic1](https://i.imgur.com/CmdKtTP.jpg), [pic2](https://i.imgur.com/s2etUo6.jpg)) on bus 3 and giraffe switches set to 01X1 (11X1 for stock LKAS), where X depends on if you have the [comma power](https://comma.ai/shop/products/power/).
|
||||
<sup>5</sup>28mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
|
||||
<sup>6</sup>Open sourced [Hyundai Giraffe](https://github.com/commaai/neo/tree/master/giraffe/hyundai) is designed for the 2019 Sante Fe; pinout may differ for other Hyundais.
|
||||
<sup>7</sup>Community built Giraffe, find more information [here](https://zoneos.com/shop/).
|
||||
|
||||
Community Maintained Cars
|
||||
------
|
||||
@@ -159,6 +161,7 @@ Directory structure
|
||||
├── pyextra # Libraries used on EON
|
||||
└── selfdrive # Code needed to drive the car
|
||||
├── assets # Fonts and images for UI
|
||||
├── athena # Allows communication with the app
|
||||
├── boardd # Daemon to talk to the board
|
||||
├── can # Helpers for parsing CAN messages
|
||||
├── car # Car specific code to read states and control actuators
|
||||
@@ -168,8 +171,6 @@ Directory structure
|
||||
├── locationd # Soon to be home of precise location
|
||||
├── logcatd # Android logcat as a service
|
||||
├── loggerd # Logger and uploader of car data
|
||||
├── mapd # Fetches map data and computes next global path
|
||||
├── orbd # Computes ORB features from frames
|
||||
├── proclogd # Logs information from proc
|
||||
├── sensord # IMU / GPS interface code
|
||||
├── test # Car simulator running code through virtual maneuvers
|
||||
|
||||
24
RELEASES.md
24
RELEASES.md
@@ -1,3 +1,27 @@
|
||||
Version 0.5.13 (2019-05-31)
|
||||
==========================
|
||||
* Reduce panda power consumption by 70%, down to 80mW, when car is off (not for GM)
|
||||
* Reduce EON power consumption by 40%, down to 1100mW, when car is off
|
||||
* Reduce CPU utilization by 20% and improve stability
|
||||
* Temporarily remove mapd functionalities to improve stability
|
||||
* Add openpilot record-only mode for unsupported cars
|
||||
* Synchronize controlsd to boardd to reduce latency
|
||||
* Remove panda support for Subaru giraffe
|
||||
|
||||
Version 0.5.12 (2019-05-16)
|
||||
==========================
|
||||
* Improve lateral control for the Prius and Prius Prime
|
||||
* Compress logs before writing to disk
|
||||
* Remove old driving data when storage reaches 90% full
|
||||
* Fix small offset in following distance
|
||||
* Various small CPU optimizations
|
||||
* Improve offroad power consumption: require NEOS Update
|
||||
* Add default speed limits for Estonia thanks to martinl!
|
||||
* Subaru Crosstrek support thanks to martinl!
|
||||
* Toyota Avalon support thanks to njbrown09!
|
||||
* Toyota Rav4 with TSS 2.0 support thanks to wocsor!
|
||||
* Toyota Corolla with TSS 2.0 support thanks to wocsor!
|
||||
|
||||
Version 0.5.11 (2019-04-17)
|
||||
========================
|
||||
* Add support for Subaru
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -6,24 +6,24 @@ GENS := gen/cpp/car.capnp.c++ gen/cpp/log.capnp.c++
|
||||
JS := gen/js/car.capnp.js gen/js/log.capnp.js
|
||||
|
||||
UNAME_M ?= $(shell uname -m)
|
||||
# only generate C++ for docker tests
|
||||
ifneq ($(OPTEST),1)
|
||||
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h
|
||||
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
ifneq (, $(shell which capnpc-java))
|
||||
GENS += gen/java/Car.java gen/java/Log.java
|
||||
else
|
||||
$(warning capnpc-java not found, skipping java build)
|
||||
endif
|
||||
endif
|
||||
GENS += gen/c/car.capnp.c gen/c/log.capnp.c gen/c/include/c++.capnp.h gen/c/include/java.capnp.h
|
||||
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
|
||||
ifneq (, $(shell which capnpc-java))
|
||||
GENS += gen/java/Car.java gen/java/Log.java
|
||||
else
|
||||
$(warning capnpc-java not found, skipping java build)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(UNAME_M),aarch64)
|
||||
CAPNPC=PATH=$(PWD)/../phonelibs/capnp-cpp/aarch64/bin/:$$PATH capnpc
|
||||
CAPNPC=PATH=$(PWD)/../phonelibs/capnp-cpp/aarch64/bin/:$$PATH capnpc
|
||||
else
|
||||
CAPNPC=capnpc
|
||||
CAPNPC=capnpc
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
|
||||
139
cereal/car.capnp
139
cereal/car.capnp
@@ -73,6 +73,8 @@ struct CarEvent @0x9b1657f34caf3ad3 {
|
||||
lowBattery @48;
|
||||
invalidGiraffeHonda @49;
|
||||
vehicleModelInvalid @50;
|
||||
controlsFailed @51;
|
||||
sensorDataInvalid @52;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +176,7 @@ struct CarState {
|
||||
|
||||
# ******* radar state @ 20hz *******
|
||||
|
||||
struct RadarState {
|
||||
struct RadarData @0x888ad6581cf0aacb {
|
||||
errors @0 :List(Error);
|
||||
points @1 :List(RadarPoint);
|
||||
|
||||
@@ -281,31 +283,84 @@ struct CarControl {
|
||||
|
||||
struct CarParams {
|
||||
carName @0 :Text;
|
||||
radarNameDEPRECATED @1 :Text;
|
||||
carFingerprint @2 :Text;
|
||||
carFingerprint @1 :Text;
|
||||
|
||||
enableSteerDEPRECATED @3 :Bool;
|
||||
enableGasInterceptor @4 :Bool;
|
||||
enableBrakeDEPRECATED @5 :Bool;
|
||||
enableCruise @6 :Bool;
|
||||
enableCamera @26 :Bool;
|
||||
enableDsu @27 :Bool; # driving support unit
|
||||
enableApgs @28 :Bool; # advanced parking guidance system
|
||||
enableGasInterceptor @2 :Bool;
|
||||
enableCruise @3 :Bool;
|
||||
enableCamera @4 :Bool;
|
||||
enableDsu @5 :Bool; # driving support unit
|
||||
enableApgs @6 :Bool; # advanced parking guidance system
|
||||
|
||||
minEnableSpeed @17 :Float32;
|
||||
minSteerSpeed @49 :Float32;
|
||||
safetyModel @18 :Int16;
|
||||
safetyParam @41 :Int16;
|
||||
minEnableSpeed @7 :Float32;
|
||||
minSteerSpeed @8 :Float32;
|
||||
safetyModel @9 :Int16;
|
||||
safetyParam @10 :Int16;
|
||||
|
||||
steerMaxBP @19 :List(Float32);
|
||||
steerMaxV @20 :List(Float32);
|
||||
gasMaxBP @21 :List(Float32);
|
||||
gasMaxV @22 :List(Float32);
|
||||
brakeMaxBP @23 :List(Float32);
|
||||
brakeMaxV @24 :List(Float32);
|
||||
steerMaxBP @11 :List(Float32);
|
||||
steerMaxV @12 :List(Float32);
|
||||
gasMaxBP @13 :List(Float32);
|
||||
gasMaxV @14 :List(Float32);
|
||||
brakeMaxBP @15 :List(Float32);
|
||||
brakeMaxV @16 :List(Float32);
|
||||
|
||||
|
||||
# things about the car in the manual
|
||||
mass @17 :Float32; # [kg] running weight
|
||||
wheelbase @18 :Float32; # [m] distance from rear to front axle
|
||||
centerToFront @19 :Float32; # [m] GC distance to front axle
|
||||
steerRatio @20 :Float32; # [] ratio between front wheels and steering wheel angles
|
||||
steerRatioRear @21 :Float32; # [] rear steering ratio wrt front steering (usually 0)
|
||||
|
||||
# things we can derive
|
||||
rotationalInertia @22 :Float32; # [kg*m2] body rotational inertia
|
||||
tireStiffnessFront @23 :Float32; # [N/rad] front tire coeff of stiff
|
||||
tireStiffnessRear @24 :Float32; # [N/rad] rear tire coeff of stiff
|
||||
|
||||
longitudinalTuning @25 :LongitudinalPIDTuning;
|
||||
lateralTuning :union {
|
||||
pid @26 :LateralPIDTuning;
|
||||
indi @27 :LateralINDITuning;
|
||||
}
|
||||
|
||||
steerLimitAlert @28 :Bool;
|
||||
|
||||
vEgoStopping @29 :Float32; # Speed at which the car goes into stopping state
|
||||
directAccelControl @30 :Bool; # Does the car have direct accel control or just gas/brake
|
||||
stoppingControl @31 :Bool; # Does the car allows full control even at lows speeds when stopping
|
||||
startAccel @32 :Float32; # Required acceleraton to overcome creep braking
|
||||
steerRateCost @33 :Float32; # Lateral MPC cost on steering rate
|
||||
steerControlType @34 :SteerControlType;
|
||||
radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN
|
||||
|
||||
steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds
|
||||
openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control?
|
||||
carVin @38 :Text; # VIN number queried during fingerprinting
|
||||
|
||||
struct LateralPIDTuning {
|
||||
kpBP @0 :List(Float32);
|
||||
kpV @1 :List(Float32);
|
||||
kiBP @2 :List(Float32);
|
||||
kiV @3 :List(Float32);
|
||||
kf @4 :Float32;
|
||||
}
|
||||
|
||||
struct LongitudinalPIDTuning {
|
||||
kpBP @0 :List(Float32);
|
||||
kpV @1 :List(Float32);
|
||||
kiBP @2 :List(Float32);
|
||||
kiV @3 :List(Float32);
|
||||
deadzoneBP @4 :List(Float32);
|
||||
deadzoneV @5 :List(Float32);
|
||||
}
|
||||
|
||||
|
||||
struct LateralINDITuning {
|
||||
outerLoopGain @0 :Float32;
|
||||
innerLoopGain @1 :Float32;
|
||||
timeConstant @2 :Float32;
|
||||
actuatorEffectiveness @3 :Float32;
|
||||
}
|
||||
|
||||
longPidDeadzoneBP @32 :List(Float32);
|
||||
longPidDeadzoneV @33 :List(Float32);
|
||||
|
||||
enum SafetyModels {
|
||||
# does NOT match board setting
|
||||
@@ -323,46 +378,6 @@ struct CarParams {
|
||||
subaru @11;
|
||||
}
|
||||
|
||||
# things about the car in the manual
|
||||
mass @7 :Float32; # [kg] running weight
|
||||
wheelbase @8 :Float32; # [m] distance from rear to front axle
|
||||
centerToFront @9 :Float32; # [m] GC distance to front axle
|
||||
steerRatio @10 :Float32; # [] ratio between front wheels and steering wheel angles
|
||||
steerRatioRear @11 :Float32; # [] rear steering ratio wrt front steering (usually 0)
|
||||
|
||||
# things we can derive
|
||||
rotationalInertia @12 :Float32; # [kg*m2] body rotational inertia
|
||||
tireStiffnessFront @13 :Float32; # [N/rad] front tire coeff of stiff
|
||||
tireStiffnessRear @14 :Float32; # [N/rad] rear tire coeff of stiff
|
||||
|
||||
# Kp and Ki for the lateral control
|
||||
steerKpBP @42 :List(Float32);
|
||||
steerKpV @43 :List(Float32);
|
||||
steerKiBP @44 :List(Float32);
|
||||
steerKiV @45 :List(Float32);
|
||||
steerKpDEPRECATED @15 :Float32;
|
||||
steerKiDEPRECATED @16 :Float32;
|
||||
steerKf @25 :Float32;
|
||||
|
||||
# Kp and Ki for the longitudinal control
|
||||
longitudinalKpBP @36 :List(Float32);
|
||||
longitudinalKpV @37 :List(Float32);
|
||||
longitudinalKiBP @38 :List(Float32);
|
||||
longitudinalKiV @39 :List(Float32);
|
||||
|
||||
steerLimitAlert @29 :Bool;
|
||||
|
||||
vEgoStopping @30 :Float32; # Speed at which the car goes into stopping state
|
||||
directAccelControl @31 :Bool; # Does the car have direct accel control or just gas/brake
|
||||
stoppingControl @34 :Bool; # Does the car allows full control even at lows speeds when stopping
|
||||
startAccel @35 :Float32; # Required acceleraton to overcome creep braking
|
||||
steerRateCost @40 :Float32; # Lateral MPC cost on steering rate
|
||||
steerControlType @46 :SteerControlType;
|
||||
radarOffCan @47 :Bool; # True when radar objects aren't visible on CAN
|
||||
|
||||
steerActuatorDelay @48 :Float32; # Steering wheel actuator delay in seconds
|
||||
openpilotLongitudinalControl @50 :Bool; # is openpilot doing the longitudinal control?
|
||||
|
||||
enum SteerControlType {
|
||||
torque @0;
|
||||
angle @1;
|
||||
|
||||
@@ -305,12 +305,12 @@ struct LiveUI {
|
||||
awarenessStatus @3 :Float32;
|
||||
}
|
||||
|
||||
struct Live20Data {
|
||||
struct RadarState @0x9a185389d6fdd05f {
|
||||
canMonoTimes @10 :List(UInt64);
|
||||
mdMonoTime @6 :UInt64;
|
||||
ftMonoTimeDEPRECATED @7 :UInt64;
|
||||
l100MonoTime @11 :UInt64;
|
||||
radarErrors @12 :List(Car.RadarState.Error);
|
||||
controlsStateMonoTime @11 :UInt64;
|
||||
radarErrors @12 :List(Car.RadarData.Error);
|
||||
|
||||
# all deprecated
|
||||
warpMatrixDEPRECATED @0 :List(Float32);
|
||||
@@ -368,15 +368,15 @@ struct LiveTracks {
|
||||
oncoming @9 :Bool;
|
||||
}
|
||||
|
||||
struct Live100Data {
|
||||
struct ControlsState @0x97ff69c53601abf1 {
|
||||
canMonoTimeDEPRECATED @16 :UInt64;
|
||||
canMonoTimes @21 :List(UInt64);
|
||||
l20MonoTimeDEPRECATED @17 :UInt64;
|
||||
radarStateMonoTimeDEPRECATED @17 :UInt64;
|
||||
mdMonoTimeDEPRECATED @18 :UInt64;
|
||||
planMonoTime @28 :UInt64;
|
||||
pathPlanMonoTime @50 :UInt64;
|
||||
|
||||
state @31 :ControlState;
|
||||
state @31 :OpenpilotState;
|
||||
vEgo @0 :Float32;
|
||||
vEgoRaw @32 :Float32;
|
||||
aEgoDEPRECATED @1 :Float32;
|
||||
@@ -388,9 +388,9 @@ struct Live100Data {
|
||||
ufAccelCmd @33 :Float32;
|
||||
yActualDEPRECATED @6 :Float32;
|
||||
yDesDEPRECATED @7 :Float32;
|
||||
upSteer @8 :Float32;
|
||||
uiSteer @9 :Float32;
|
||||
ufSteer @34 :Float32;
|
||||
upSteerDEPRECATED @8 :Float32;
|
||||
uiSteerDEPRECATED @9 :Float32;
|
||||
ufSteerDEPRECATED @34 :Float32;
|
||||
aTargetMinDEPRECATED @10 :Float32;
|
||||
aTargetMaxDEPRECATED @11 :Float32;
|
||||
aTarget @35 :Float32;
|
||||
@@ -428,7 +428,12 @@ struct Live100Data {
|
||||
vCurvature @46 :Float32;
|
||||
decelForTurn @47 :Bool;
|
||||
|
||||
enum ControlState {
|
||||
lateralControlState :union {
|
||||
indiState @52 :LateralINDIState;
|
||||
pidState @53 :LateralPIDState;
|
||||
}
|
||||
|
||||
enum OpenpilotState @0xdbe58b96d2d1ac61 {
|
||||
disabled @0;
|
||||
preEnabled @1;
|
||||
enabled @2;
|
||||
@@ -455,6 +460,31 @@ struct Live100Data {
|
||||
full @3; # full screen
|
||||
}
|
||||
|
||||
struct LateralINDIState {
|
||||
active @0 :Bool;
|
||||
steerAngle @1 :Float32;
|
||||
steerRate @2 :Float32;
|
||||
steerAccel @3 :Float32;
|
||||
rateSetPoint @4 :Float32;
|
||||
accelSetPoint @5 :Float32;
|
||||
accelError @6 :Float32;
|
||||
delayedOutput @7 :Float32;
|
||||
delta @8 :Float32;
|
||||
output @9 :Float32;
|
||||
}
|
||||
|
||||
struct LateralPIDState {
|
||||
active @0 :Bool;
|
||||
steerAngle @1 :Float32;
|
||||
steerRate @2 :Float32;
|
||||
angleError @3 :Float32;
|
||||
p @4 :Float32;
|
||||
i @5 :Float32;
|
||||
f @6 :Float32;
|
||||
output @7 :Float32;
|
||||
saturated @8 :Bool;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct LiveEventData {
|
||||
@@ -477,6 +507,7 @@ struct ModelData {
|
||||
points @0 :List(Float32);
|
||||
prob @1 :Float32;
|
||||
std @2 :Float32;
|
||||
stds @3 :List(Float32);
|
||||
}
|
||||
|
||||
struct LeadData {
|
||||
@@ -544,8 +575,8 @@ struct LogRotate {
|
||||
|
||||
struct Plan {
|
||||
mdMonoTime @9 :UInt64;
|
||||
l20MonoTime @10 :UInt64;
|
||||
events @13 :List(Car.CarEvent);
|
||||
radarStateMonoTime @10 :UInt64;
|
||||
eventsDEPRECATED @13 :List(Car.CarEvent);
|
||||
|
||||
# lateral, 3rd order polynomial
|
||||
lateralValidDEPRECATED @0 :Bool;
|
||||
@@ -583,6 +614,7 @@ struct Plan {
|
||||
decelForTurn @22 :Bool;
|
||||
mapValid @25 :Bool;
|
||||
radarValid @28 :Bool;
|
||||
radarCommIssue @30 :Bool;
|
||||
|
||||
processingDelay @29 :Float32;
|
||||
|
||||
@@ -617,6 +649,7 @@ struct PathPlan {
|
||||
paramsValid @10 :Bool;
|
||||
modelValid @12 :Bool;
|
||||
angleOffset @11 :Float32;
|
||||
sensorValid @14 :Bool;
|
||||
}
|
||||
|
||||
struct LiveLocationData {
|
||||
@@ -1612,6 +1645,7 @@ struct LiveParametersData {
|
||||
angleOffsetAverage @3 :Float32;
|
||||
stiffnessFactor @4 :Float32;
|
||||
steerRatio @5 :Float32;
|
||||
sensorValid @6 :Bool;
|
||||
}
|
||||
|
||||
struct LiveMapData {
|
||||
@@ -1659,13 +1693,13 @@ struct Event {
|
||||
sensorEventDEPRECATED @4 :SensorEventData;
|
||||
can @5 :List(CanData);
|
||||
thermal @6 :ThermalData;
|
||||
live100 @7 :Live100Data;
|
||||
controlsState @7 :ControlsState;
|
||||
liveEventDEPRECATED @8 :List(LiveEventData);
|
||||
model @9 :ModelData;
|
||||
features @10 :CalibrationFeatures;
|
||||
sensorEvents @11 :List(SensorEventData);
|
||||
health @12 :HealthData;
|
||||
live20 @13 :Live20Data;
|
||||
radarState @13 :RadarState;
|
||||
liveUIDEPRECATED @14 :LiveUI;
|
||||
encodeIdx @15 :EncodeIndex;
|
||||
liveTracks @16 :List(LiveTracks);
|
||||
|
||||
11
check_code_quality.sh
Normal file
11
check_code_quality.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
pyflakes $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")
|
||||
RESULT=$?
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
pylint $(find . -iname "*.py" | grep -vi "^\./pyextra.*" | grep -vi "^\./panda")
|
||||
RESULT=$? & 3
|
||||
fi
|
||||
|
||||
[ $RESULT -ne 0 ] && exit 1
|
||||
exit 0
|
||||
16
common/clock.pyx
Normal file
16
common/clock.pyx
Normal file
@@ -0,0 +1,16 @@
|
||||
from posix.time cimport clock_gettime, timespec, CLOCK_BOOTTIME, CLOCK_MONOTONIC_RAW
|
||||
|
||||
cdef double readclock(int clock_id):
|
||||
cdef timespec ts
|
||||
cdef double current
|
||||
|
||||
clock_gettime(clock_id, &ts)
|
||||
current = ts.tv_sec + (ts.tv_nsec / 1000000000.)
|
||||
return current
|
||||
|
||||
|
||||
def monotonic_time():
|
||||
return readclock(CLOCK_MONOTONIC_RAW)
|
||||
|
||||
def sec_since_boot():
|
||||
return readclock(CLOCK_BOOTTIME)
|
||||
103
common/file_helpers.py
Normal file
103
common/file_helpers.py
Normal file
@@ -0,0 +1,103 @@
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from atomicwrites import AtomicWriter
|
||||
|
||||
def mkdirs_exists_ok(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
except OSError:
|
||||
if not os.path.isdir(path):
|
||||
raise
|
||||
|
||||
def rm_not_exists_ok(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
except OSError:
|
||||
if os.path.exists(path):
|
||||
raise
|
||||
|
||||
def rm_tree_or_link(path):
|
||||
if os.path.islink(path):
|
||||
os.unlink(path)
|
||||
elif os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
def get_tmpdir_on_same_filesystem(path):
|
||||
# TODO(mgraczyk): HACK, we should actually check for which filesystem.
|
||||
normpath = os.path.normpath(path)
|
||||
parts = normpath.split("/")
|
||||
if len(parts) > 1:
|
||||
if parts[1].startswith("raid"):
|
||||
if len(parts) > 2 and parts[2] == "runner":
|
||||
return "/{}/runner/tmp".format(parts[1])
|
||||
elif len(parts) > 2 and parts[2] == "aws":
|
||||
return "/{}/aws/tmp".format(parts[1])
|
||||
else:
|
||||
return "/{}/tmp".format(parts[1])
|
||||
elif parts[1] == "aws":
|
||||
return "/aws/tmp"
|
||||
elif parts[1] == "scratch":
|
||||
return "/scratch/tmp"
|
||||
return "/tmp"
|
||||
|
||||
class AutoMoveTempdir(object):
|
||||
def __init__(self, target_path, temp_dir=None):
|
||||
self._target_path = target_path
|
||||
self._path = tempfile.mkdtemp(dir=temp_dir)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._path
|
||||
|
||||
def close(self):
|
||||
os.rename(self._path, self._target_path)
|
||||
|
||||
def __enter__(self): return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
if type is None:
|
||||
self.close()
|
||||
else:
|
||||
shutil.rmtree(self._path)
|
||||
|
||||
class NamedTemporaryDir(object):
|
||||
def __init__(self, temp_dir=None):
|
||||
self._path = tempfile.mkdtemp(dir=temp_dir)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._path
|
||||
|
||||
def close(self):
|
||||
shutil.rmtree(self._path)
|
||||
|
||||
def __enter__(self): return self
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.close()
|
||||
|
||||
def _get_fileobject_func(writer, temp_dir):
|
||||
def _get_fileobject():
|
||||
file_obj = writer.get_fileobject(dir=temp_dir)
|
||||
os.chmod(file_obj.name, 0o644)
|
||||
return file_obj
|
||||
return _get_fileobject
|
||||
|
||||
def atomic_write_on_fs_tmp(path, **kwargs):
|
||||
"""Creates an atomic writer using a temporary file in a temporary directory
|
||||
on the same filesystem as path.
|
||||
"""
|
||||
# TODO(mgraczyk): This use of AtomicWriter relies on implementation details to set the temp
|
||||
# directory.
|
||||
writer = AtomicWriter(path, **kwargs)
|
||||
return writer._open(_get_fileobject_func(writer, get_tmpdir_on_same_filesystem(path)))
|
||||
|
||||
|
||||
def atomic_write_in_dir(path, **kwargs):
|
||||
"""Creates an atomic writer using a temporary file in the same directory
|
||||
as the destination file.
|
||||
"""
|
||||
writer = AtomicWriter(path, **kwargs)
|
||||
return writer._open(_get_fileobject_func(writer, os.path.dirname(path)))
|
||||
|
||||
10
common/kalman/Makefile
Normal file
10
common/kalman/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
all: simple_kalman_impl.so
|
||||
|
||||
simple_kalman_impl.so: simple_kalman_impl.pyx simple_kalman_impl.pxd simple_kalman_setup.py
|
||||
python simple_kalman_setup.py build_ext --inplace
|
||||
rm -rf build
|
||||
rm simple_kalman_impl.c
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f simple_kalman_impl.so
|
||||
@@ -1,23 +1,10 @@
|
||||
import numpy as np
|
||||
# pylint: skip-file
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
kalman_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
subprocess.check_call(["make", "simple_kalman_impl.so"], cwd=kalman_dir)
|
||||
|
||||
class KF1D:
|
||||
# this EKF assumes constant covariance matrix, so calculations are much simpler
|
||||
# the Kalman gain also needs to be precomputed using the control module
|
||||
|
||||
def __init__(self, x0, A, C, K):
|
||||
self.x = x0
|
||||
self.A = A
|
||||
self.C = C
|
||||
self.K = K
|
||||
|
||||
self.A_K = self.A - np.dot(self.K, self.C)
|
||||
|
||||
# K matrix needs to be pre-computed as follow:
|
||||
# import control
|
||||
# (x, l, K) = control.dare(np.transpose(self.A), np.transpose(self.C), Q, R)
|
||||
# self.K = np.transpose(K)
|
||||
|
||||
def update(self, meas):
|
||||
self.x = np.dot(self.A_K, self.x) + np.dot(self.K, meas)
|
||||
return self.x
|
||||
from simple_kalman_impl import KF1D as KF1D
|
||||
# Silence pyflakes
|
||||
assert KF1D
|
||||
|
||||
16
common/kalman/simple_kalman_impl.pxd
Normal file
16
common/kalman/simple_kalman_impl.pxd
Normal file
@@ -0,0 +1,16 @@
|
||||
cdef class KF1D:
|
||||
cdef public:
|
||||
double x0_0
|
||||
double x1_0
|
||||
double K0_0
|
||||
double K1_0
|
||||
double A0_0
|
||||
double A0_1
|
||||
double A1_0
|
||||
double A1_1
|
||||
double C0_0
|
||||
double C0_1
|
||||
double A_K_0
|
||||
double A_K_1
|
||||
double A_K_2
|
||||
double A_K_3
|
||||
35
common/kalman/simple_kalman_impl.pyx
Normal file
35
common/kalman/simple_kalman_impl.pyx
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
cdef class KF1D:
|
||||
def __init__(self, x0, A, C, K):
|
||||
self.x0_0 = x0[0][0]
|
||||
self.x1_0 = x0[1][0]
|
||||
self.A0_0 = A[0][0]
|
||||
self.A0_1 = A[0][1]
|
||||
self.A1_0 = A[1][0]
|
||||
self.A1_1 = A[1][1]
|
||||
self.C0_0 = C[0]
|
||||
self.C0_1 = C[1]
|
||||
self.K0_0 = K[0][0]
|
||||
self.K1_0 = K[1][0]
|
||||
|
||||
self.A_K_0 = self.A0_0 - self.K0_0 * self.C0_0
|
||||
self.A_K_1 = self.A0_1 - self.K0_0 * self.C0_1
|
||||
self.A_K_2 = self.A1_0 - self.K1_0 * self.C0_0
|
||||
self.A_K_3 = self.A1_1 - self.K1_0 * self.C0_1
|
||||
|
||||
def update(self, meas):
|
||||
cdef double x0_0 = self.A_K_0 * self.x0_0 + self.A_K_1 * self.x1_0 + self.K0_0 * meas
|
||||
cdef double x1_0 = self.A_K_2 * self.x0_0 + self.A_K_3 * self.x1_0 + self.K1_0 * meas
|
||||
self.x0_0 = x0_0
|
||||
self.x1_0 = x1_0
|
||||
|
||||
return [self.x0_0, self.x1_0]
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return [[self.x0_0], [self.x1_0]]
|
||||
|
||||
@x.setter
|
||||
def x(self, x):
|
||||
self.x0_0 = x[0][0]
|
||||
self.x1_0 = x[1][0]
|
||||
23
common/kalman/simple_kalman_old.py
Normal file
23
common/kalman/simple_kalman_old.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
class KF1D:
|
||||
# this EKF assumes constant covariance matrix, so calculations are much simpler
|
||||
# the Kalman gain also needs to be precomputed using the control module
|
||||
|
||||
def __init__(self, x0, A, C, K):
|
||||
self.x = x0
|
||||
self.A = A
|
||||
self.C = C
|
||||
self.K = K
|
||||
|
||||
self.A_K = self.A - np.dot(self.K, self.C)
|
||||
|
||||
# K matrix needs to be pre-computed as follow:
|
||||
# import control
|
||||
# (x, l, K) = control.dare(np.transpose(self.A), np.transpose(self.C), Q, R)
|
||||
# self.K = np.transpose(K)
|
||||
|
||||
def update(self, meas):
|
||||
self.x = np.dot(self.A_K, self.x) + np.dot(self.K, meas)
|
||||
return self.x
|
||||
5
common/kalman/simple_kalman_setup.py
Normal file
5
common/kalman/simple_kalman_setup.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from distutils.core import setup, Extension
|
||||
from Cython.Build import cythonize
|
||||
|
||||
setup(name='Simple Kalman Implementation',
|
||||
ext_modules=cythonize(Extension("simple_kalman_impl", ["simple_kalman_impl.pyx"])))
|
||||
116
common/kalman/tests/test_ekf.py
Normal file
116
common/kalman/tests/test_ekf.py
Normal file
@@ -0,0 +1,116 @@
|
||||
import numpy as np
|
||||
import numpy.matlib
|
||||
import unittest
|
||||
import timeit
|
||||
|
||||
from common.kalman.ekf import EKF, SimpleSensor, FastEKF1D
|
||||
|
||||
class TestEKF(EKF):
|
||||
def __init__(self, var_init, Q):
|
||||
super(TestEKF, self).__init__(False)
|
||||
self.identity = numpy.matlib.identity(2)
|
||||
self.state = numpy.matlib.zeros((2, 1))
|
||||
self.covar = self.identity * var_init
|
||||
|
||||
self.process_noise = numpy.matlib.diag(Q)
|
||||
|
||||
def calc_transfer_fun(self, dt):
|
||||
tf = numpy.matlib.identity(2)
|
||||
tf[0, 1] = dt
|
||||
return tf, tf
|
||||
|
||||
|
||||
class EKFTest(unittest.TestCase):
|
||||
def test_update_scalar(self):
|
||||
ekf = TestEKF(1e3, [0.1, 1])
|
||||
dt = 1. / 100
|
||||
|
||||
sensor = SimpleSensor(0, 1, 2)
|
||||
readings = map(sensor.read, np.arange(100, 300))
|
||||
|
||||
for reading in readings:
|
||||
ekf.update_scalar(reading)
|
||||
ekf.predict(dt)
|
||||
|
||||
np.testing.assert_allclose(ekf.state, [[300], [100]], 1e-4)
|
||||
np.testing.assert_allclose(
|
||||
ekf.covar,
|
||||
np.asarray([[0.0563, 0.10278], [0.10278, 0.55779]]),
|
||||
atol=1e-4)
|
||||
|
||||
def test_unbiased(self):
|
||||
ekf = TestEKF(1e3, [0., 0.])
|
||||
dt = np.float64(1. / 100)
|
||||
|
||||
sensor = SimpleSensor(0, 1, 2)
|
||||
readings = map(sensor.read, np.arange(1000))
|
||||
|
||||
for reading in readings:
|
||||
ekf.update_scalar(reading)
|
||||
ekf.predict(dt)
|
||||
|
||||
np.testing.assert_allclose(ekf.state, [[1000.], [100.]], 1e-4)
|
||||
|
||||
|
||||
class FastEKF1DTest(unittest.TestCase):
|
||||
def test_correctness(self):
|
||||
dt = 1. / 100
|
||||
reading = SimpleSensor(0, 1, 2).read(100)
|
||||
|
||||
ekf = TestEKF(1e3, [0.1, 1])
|
||||
fast_ekf = FastEKF1D(dt, 1e3, [0.1, 1])
|
||||
|
||||
ekf.update_scalar(reading)
|
||||
fast_ekf.update_scalar(reading)
|
||||
self.assertAlmostEqual(ekf.state[0] , fast_ekf.state[0])
|
||||
self.assertAlmostEqual(ekf.state[1] , fast_ekf.state[1])
|
||||
self.assertAlmostEqual(ekf.covar[0, 0], fast_ekf.covar[0])
|
||||
self.assertAlmostEqual(ekf.covar[0, 1], fast_ekf.covar[2])
|
||||
self.assertAlmostEqual(ekf.covar[1, 1], fast_ekf.covar[1])
|
||||
|
||||
ekf.predict(dt)
|
||||
fast_ekf.predict(dt)
|
||||
self.assertAlmostEqual(ekf.state[0] , fast_ekf.state[0])
|
||||
self.assertAlmostEqual(ekf.state[1] , fast_ekf.state[1])
|
||||
self.assertAlmostEqual(ekf.covar[0, 0], fast_ekf.covar[0])
|
||||
self.assertAlmostEqual(ekf.covar[0, 1], fast_ekf.covar[2])
|
||||
self.assertAlmostEqual(ekf.covar[1, 1], fast_ekf.covar[1])
|
||||
|
||||
def test_speed(self):
|
||||
setup = """
|
||||
import numpy as np
|
||||
from common.kalman.tests.test_ekf import TestEKF
|
||||
from common.kalman.ekf import SimpleSensor, FastEKF1D
|
||||
|
||||
dt = 1. / 100
|
||||
reading = SimpleSensor(0, 1, 2).read(100)
|
||||
|
||||
var_init, Q = 1e3, [0.1, 1]
|
||||
ekf = TestEKF(var_init, Q)
|
||||
fast_ekf = FastEKF1D(dt, var_init, Q)
|
||||
"""
|
||||
|
||||
timeit.timeit("""
|
||||
ekf.update_scalar(reading)
|
||||
ekf.predict(dt)
|
||||
""", setup=setup, number=1000)
|
||||
|
||||
ekf_speed = timeit.timeit("""
|
||||
ekf.update_scalar(reading)
|
||||
ekf.predict(dt)
|
||||
""", setup=setup, number=20000)
|
||||
|
||||
timeit.timeit("""
|
||||
fast_ekf.update_scalar(reading)
|
||||
fast_ekf.predict(dt)
|
||||
""", setup=setup, number=1000)
|
||||
|
||||
fast_ekf_speed = timeit.timeit("""
|
||||
fast_ekf.update_scalar(reading)
|
||||
fast_ekf.predict(dt)
|
||||
""", setup=setup, number=20000)
|
||||
|
||||
assert fast_ekf_speed < ekf_speed / 4
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
85
common/kalman/tests/test_simple_kalman.py
Normal file
85
common/kalman/tests/test_simple_kalman.py
Normal file
@@ -0,0 +1,85 @@
|
||||
import unittest
|
||||
import random
|
||||
import timeit
|
||||
import numpy as np
|
||||
|
||||
from common.kalman.simple_kalman import KF1D
|
||||
from common.kalman.simple_kalman_old import KF1D as KF1D_old
|
||||
|
||||
|
||||
class TestSimpleKalman(unittest.TestCase):
|
||||
def setUp(self):
|
||||
dt = 0.01
|
||||
x0_0 = 0.0
|
||||
x1_0 = 0.0
|
||||
A0_0 = 1.0
|
||||
A0_1 = dt
|
||||
A1_0 = 0.0
|
||||
A1_1 = 1.0
|
||||
C0_0 = 1.0
|
||||
C0_1 = 0.0
|
||||
K0_0 = 0.12287673
|
||||
K1_0 = 0.29666309
|
||||
|
||||
self.kf_old = KF1D_old(x0=np.matrix([[x0_0], [x1_0]]),
|
||||
A=np.matrix([[A0_0, A0_1], [A1_0, A1_1]]),
|
||||
C=np.matrix([C0_0, C0_1]),
|
||||
K=np.matrix([[K0_0], [K1_0]]))
|
||||
|
||||
self.kf = KF1D(x0=[[x0_0], [x1_0]],
|
||||
A=[[A0_0, A0_1], [A1_0, A1_1]],
|
||||
C=[C0_0, C0_1],
|
||||
K=[[K0_0], [K1_0]])
|
||||
|
||||
def test_getter_setter(self):
|
||||
self.kf.x = [[1.0], [1.0]]
|
||||
self.assertEqual(self.kf.x, [[1.0], [1.0]])
|
||||
|
||||
def update_returns_state(self):
|
||||
x = self.kf.update(100)
|
||||
self.assertEqual(x, self.kf.x)
|
||||
|
||||
def test_old_equal_new(self):
|
||||
for _ in range(1000):
|
||||
v_wheel = random.uniform(0, 200)
|
||||
|
||||
x_old = self.kf_old.update(v_wheel)
|
||||
x = self.kf.update(v_wheel)
|
||||
|
||||
# Compare the output x, verify that the error is less than 1e-4
|
||||
self.assertAlmostEqual(x_old[0], x[0])
|
||||
self.assertAlmostEqual(x_old[1], x[1])
|
||||
|
||||
|
||||
def test_new_is_faster(self):
|
||||
setup = """
|
||||
import numpy as np
|
||||
|
||||
from common.kalman.simple_kalman import KF1D
|
||||
from common.kalman.simple_kalman_old import KF1D as KF1D_old
|
||||
|
||||
dt = 0.01
|
||||
x0_0 = 0.0
|
||||
x1_0 = 0.0
|
||||
A0_0 = 1.0
|
||||
A0_1 = dt
|
||||
A1_0 = 0.0
|
||||
A1_1 = 1.0
|
||||
C0_0 = 1.0
|
||||
C0_1 = 0.0
|
||||
K0_0 = 0.12287673
|
||||
K1_0 = 0.29666309
|
||||
|
||||
kf_old = KF1D_old(x0=np.matrix([[x0_0], [x1_0]]),
|
||||
A=np.matrix([[A0_0, A0_1], [A1_0, A1_1]]),
|
||||
C=np.matrix([C0_0, C0_1]),
|
||||
K=np.matrix([[K0_0], [K1_0]]))
|
||||
|
||||
kf = KF1D(x0=[[x0_0], [x1_0]],
|
||||
A=[[A0_0, A0_1], [A1_0, A1_1]],
|
||||
C=[C0_0, C0_1],
|
||||
K=[[K0_0], [K1_0]])
|
||||
"""
|
||||
kf_speed = timeit.timeit("kf.update(1234)", setup=setup, number=10000)
|
||||
kf_old_speed = timeit.timeit("kf_old.update(1234)", setup=setup, number=10000)
|
||||
self.assertTrue(kf_speed < kf_old_speed / 4)
|
||||
@@ -41,7 +41,7 @@ def mkdirs_exists_ok(path):
|
||||
class TxType(Enum):
|
||||
PERSISTENT = 1
|
||||
CLEAR_ON_MANAGER_START = 2
|
||||
CLEAR_ON_CAR_START = 3
|
||||
CLEAR_ON_PANDA_DISCONNECT = 3
|
||||
|
||||
|
||||
class UnknownKeyName(Exception):
|
||||
@@ -49,32 +49,33 @@ class UnknownKeyName(Exception):
|
||||
|
||||
|
||||
keys = {
|
||||
"AccessToken": TxType.PERSISTENT,
|
||||
"CalibrationParams": TxType.PERSISTENT,
|
||||
"CarParams": TxType.CLEAR_ON_CAR_START,
|
||||
"CompletedTrainingVersion": TxType.PERSISTENT,
|
||||
"ControlsParams": TxType.PERSISTENT,
|
||||
"DoUninstall": TxType.CLEAR_ON_MANAGER_START,
|
||||
"DongleId": TxType.PERSISTENT,
|
||||
"GitBranch": TxType.PERSISTENT,
|
||||
"GitCommit": TxType.PERSISTENT,
|
||||
"GitRemote": TxType.PERSISTENT,
|
||||
"HasAcceptedTerms": TxType.PERSISTENT,
|
||||
"IsDriverMonitoringEnabled": TxType.PERSISTENT,
|
||||
"IsFcwEnabled": TxType.PERSISTENT,
|
||||
"IsGeofenceEnabled": TxType.PERSISTENT,
|
||||
"IsMetric": TxType.PERSISTENT,
|
||||
"IsUpdateAvailable": TxType.PERSISTENT,
|
||||
"IsUploadVideoOverCellularEnabled": TxType.PERSISTENT,
|
||||
"LimitSetSpeed": TxType.PERSISTENT,
|
||||
"LiveParameters": TxType.PERSISTENT,
|
||||
"LongitudinalControl": TxType.PERSISTENT,
|
||||
"Passive": TxType.PERSISTENT,
|
||||
"RecordFront": TxType.PERSISTENT,
|
||||
"ShouldDoUpdate": TxType.CLEAR_ON_MANAGER_START,
|
||||
"SpeedLimitOffset": TxType.PERSISTENT,
|
||||
"TrainingVersion": TxType.PERSISTENT,
|
||||
"Version": TxType.PERSISTENT,
|
||||
"AccessToken": [TxType.PERSISTENT],
|
||||
"CalibrationParams": [TxType.PERSISTENT],
|
||||
"CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
|
||||
"CompletedTrainingVersion": [TxType.PERSISTENT],
|
||||
"ControlsParams": [TxType.PERSISTENT],
|
||||
"DoUninstall": [TxType.CLEAR_ON_MANAGER_START],
|
||||
"DongleId": [TxType.PERSISTENT],
|
||||
"GitBranch": [TxType.PERSISTENT],
|
||||
"GitCommit": [TxType.PERSISTENT],
|
||||
"GitRemote": [TxType.PERSISTENT],
|
||||
"HasAcceptedTerms": [TxType.PERSISTENT],
|
||||
"IsDriverMonitoringEnabled": [TxType.PERSISTENT],
|
||||
"IsFcwEnabled": [TxType.PERSISTENT],
|
||||
"IsGeofenceEnabled": [TxType.PERSISTENT],
|
||||
"IsMetric": [TxType.PERSISTENT],
|
||||
"IsUpdateAvailable": [TxType.PERSISTENT],
|
||||
"IsUploadVideoOverCellularEnabled": [TxType.PERSISTENT],
|
||||
"LimitSetSpeed": [TxType.PERSISTENT],
|
||||
"LiveParameters": [TxType.PERSISTENT],
|
||||
"LongitudinalControl": [TxType.PERSISTENT],
|
||||
"Passive": [TxType.PERSISTENT],
|
||||
"RecordFront": [TxType.PERSISTENT],
|
||||
"ShouldDoUpdate": [TxType.CLEAR_ON_MANAGER_START],
|
||||
"SpeedLimitOffset": [TxType.PERSISTENT],
|
||||
"SubscriberInfo": [TxType.PERSISTENT],
|
||||
"TrainingVersion": [TxType.PERSISTENT],
|
||||
"Version": [TxType.PERSISTENT],
|
||||
}
|
||||
|
||||
|
||||
@@ -308,14 +309,14 @@ class Params(object):
|
||||
def _clear_keys_with_type(self, tx_type):
|
||||
with self.transaction(write=True) as txn:
|
||||
for key in keys:
|
||||
if keys[key] == tx_type:
|
||||
if tx_type in keys[key]:
|
||||
txn.delete(key)
|
||||
|
||||
def manager_start(self):
|
||||
self._clear_keys_with_type(TxType.CLEAR_ON_MANAGER_START)
|
||||
|
||||
def car_start(self):
|
||||
self._clear_keys_with_type(TxType.CLEAR_ON_CAR_START)
|
||||
def panda_disconnect(self):
|
||||
self._clear_keys_with_type(TxType.CLEAR_ON_PANDA_DISCONNECT)
|
||||
|
||||
def delete(self, key):
|
||||
with self.transaction(write=True) as txn:
|
||||
|
||||
@@ -2,58 +2,24 @@
|
||||
import os
|
||||
import time
|
||||
import platform
|
||||
import threading
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
|
||||
from cffi import FFI
|
||||
|
||||
# Build and load cython module
|
||||
import pyximport
|
||||
installer = pyximport.install(inplace=True, build_dir='/tmp')
|
||||
from common.clock import monotonic_time, sec_since_boot # pylint: disable=no-name-in-module, import-error
|
||||
pyximport.uninstall(*installer)
|
||||
assert monotonic_time
|
||||
assert sec_since_boot
|
||||
|
||||
|
||||
ffi = FFI()
|
||||
ffi.cdef("""
|
||||
|
||||
typedef int clockid_t;
|
||||
struct timespec {
|
||||
long tv_sec; /* Seconds. */
|
||||
long tv_nsec; /* Nanoseconds. */
|
||||
};
|
||||
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||
|
||||
long syscall(long number, ...);
|
||||
|
||||
"""
|
||||
)
|
||||
ffi.cdef("long syscall(long number, ...);")
|
||||
libc = ffi.dlopen(None)
|
||||
|
||||
|
||||
# see <linux/time.h>
|
||||
CLOCK_MONOTONIC_RAW = 4
|
||||
CLOCK_BOOTTIME = 7
|
||||
|
||||
if platform.system() != 'Darwin' and hasattr(libc, 'clock_gettime'):
|
||||
c_clock_gettime = libc.clock_gettime
|
||||
|
||||
tlocal = threading.local()
|
||||
def clock_gettime(clk_id):
|
||||
if not hasattr(tlocal, 'ts'):
|
||||
tlocal.ts = ffi.new('struct timespec *')
|
||||
|
||||
ts = tlocal.ts
|
||||
|
||||
r = c_clock_gettime(clk_id, ts)
|
||||
if r != 0:
|
||||
raise OSError("clock_gettime")
|
||||
return ts.tv_sec + ts.tv_nsec * 1e-9
|
||||
else:
|
||||
# hack. only for OS X < 10.12
|
||||
def clock_gettime(clk_id):
|
||||
return time.time()
|
||||
|
||||
def monotonic_time():
|
||||
return clock_gettime(CLOCK_MONOTONIC_RAW)
|
||||
|
||||
def sec_since_boot():
|
||||
return clock_gettime(CLOCK_BOOTTIME)
|
||||
|
||||
|
||||
def set_realtime_priority(level):
|
||||
if os.getuid() != 0:
|
||||
print("not setting priority, not root")
|
||||
@@ -99,10 +65,9 @@ class Ratekeeper(object):
|
||||
lagged = False
|
||||
remaining = self._next_frame_time - sec_since_boot()
|
||||
self._next_frame_time += self._interval
|
||||
if remaining < -self._print_delay_threshold:
|
||||
if self._print_delay_threshold is not None and remaining < -self._print_delay_threshold:
|
||||
print("%s lagging by %.2f ms" % (self._process_name, -remaining * 1000))
|
||||
lagged = True
|
||||
self._frame += 1
|
||||
self._remaining = remaining
|
||||
return lagged
|
||||
|
||||
|
||||
28
common/timeout.py
Normal file
28
common/timeout.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import signal
|
||||
|
||||
class TimeoutException(Exception):
|
||||
pass
|
||||
|
||||
class Timeout:
|
||||
"""
|
||||
Timeout context manager.
|
||||
For example this code will raise a TimeoutException:
|
||||
with Timeout(seconds=5, error_msg="Sleep was too long"):
|
||||
time.sleep(10)
|
||||
"""
|
||||
def __init__(self, seconds, error_msg=None):
|
||||
if error_msg is None:
|
||||
error_msg = 'Timed out after {} seconds'.format(seconds)
|
||||
self.seconds = seconds
|
||||
self.error_msg = error_msg
|
||||
|
||||
def handle_timeout(self, signume, frame):
|
||||
raise TimeoutException(self.error_msg)
|
||||
|
||||
def __enter__(self):
|
||||
signal.signal(signal.SIGALRM, self.handle_timeout)
|
||||
signal.alarm(self.seconds)
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
signal.alarm(0)
|
||||
|
||||
@@ -200,3 +200,14 @@ def transform_img(base_img,
|
||||
augmented_rgb[:cyy] = cv2.warpPerspective(base_img, M, (output_size[0], cyy), borderMode=cv2.BORDER_REPLICATE)
|
||||
|
||||
return augmented_rgb
|
||||
|
||||
def yuv_crop(frame, output_size, center=None):
|
||||
# output_size in camera coordinates so u,v
|
||||
# center in array coordinates so row, column
|
||||
rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2RGB_I420)
|
||||
if not center:
|
||||
center = (rgb.shape[0]/2, rgb.shape[1]/2)
|
||||
rgb_crop = rgb[center[0] - output_size[1]/2: center[0] + output_size[1]/2,
|
||||
center[1] - output_size[0]/2: center[1] + output_size[0]/2]
|
||||
return cv2.cvtColor(rgb_crop, cv2.COLOR_RGB2YUV_I420)
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
from common.transformations.camera import eon_focal_length, \
|
||||
vp_from_ke, \
|
||||
get_view_frame_from_road_frame, \
|
||||
vp_from_ke, get_view_frame_from_road_frame, \
|
||||
FULL_FRAME_SIZE
|
||||
|
||||
# segnet
|
||||
@@ -117,6 +116,16 @@ def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model
|
||||
return np.dot(camera_from_model_camera, model_camera_from_model_frame)
|
||||
|
||||
|
||||
def get_camera_frame_from_medmodel_frame(camera_frame_from_road_frame):
|
||||
camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)]
|
||||
medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)]
|
||||
|
||||
ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground)
|
||||
camera_frame_from_medmodel_frame = np.dot(camera_frame_from_ground, ground_from_medmodel_frame)
|
||||
|
||||
return camera_frame_from_medmodel_frame
|
||||
|
||||
|
||||
def get_camera_frame_from_bigmodel_frame(camera_frame_from_road_frame):
|
||||
camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)]
|
||||
bigmodel_frame_from_ground = bigmodel_frame_from_road_frame[:, (0, 1, 3)]
|
||||
|
||||
95
common/vin.py
Executable file
95
common/vin.py
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python
|
||||
import time
|
||||
from common.realtime import sec_since_boot
|
||||
import selfdrive.messaging as messaging
|
||||
from selfdrive.boardd.boardd import can_list_to_can_capnp
|
||||
|
||||
def get_vin(logcan, sendcan):
|
||||
|
||||
# works on standard 11-bit addresses for diagnostic. Tested on Toyota and Subaru;
|
||||
# Honda uses the extended 29-bit addresses, and unfortunately only works from OBDII
|
||||
query_msg = [[0x7df, 0, '\x02\x09\x02'.ljust(8, "\x00"), 0],
|
||||
[0x7e0, 0, '\x30'.ljust(8, "\x00"), 0]]
|
||||
|
||||
cnts = [1, 2] # Number of messages to wait for at each iteration
|
||||
vin_valid = True
|
||||
|
||||
dat = []
|
||||
for i in range(len(query_msg)):
|
||||
cnt = 0
|
||||
sendcan.send(can_list_to_can_capnp([query_msg[i]], msgtype='sendcan'))
|
||||
got_response = False
|
||||
t_start = sec_since_boot()
|
||||
while sec_since_boot() - t_start < 0.05 and not got_response:
|
||||
for a in messaging.drain_sock(logcan):
|
||||
for can in a.can:
|
||||
if can.src == 0 and can.address == 0x7e8:
|
||||
vin_valid = vin_valid and is_vin_response_valid(can.dat, i, cnt)
|
||||
dat += can.dat[2:] if i == 0 else can.dat[1:]
|
||||
cnt += 1
|
||||
if cnt == cnts[i]:
|
||||
got_response = True
|
||||
time.sleep(0.01)
|
||||
|
||||
return "".join(dat[3:]) if vin_valid else ""
|
||||
|
||||
"""
|
||||
if 'vin' not in gctx:
|
||||
print "getting vin"
|
||||
gctx['vin'] = query_vin()[3:]
|
||||
print "got VIN %s" % (gctx['vin'],)
|
||||
cloudlog.info("got VIN %s" % (gctx['vin'],))
|
||||
|
||||
# *** determine platform based on VIN ****
|
||||
if vin.startswith("19UDE2F36G"):
|
||||
print "ACURA ILX 2016"
|
||||
self.civic = False
|
||||
else:
|
||||
# TODO: add Honda check explicitly
|
||||
print "HONDA CIVIC 2016"
|
||||
self.civic = True
|
||||
|
||||
# *** special case VIN of Acura test platform
|
||||
if vin == "19UDE2F36GA001322":
|
||||
print "comma.ai test platform detected"
|
||||
# it has a gas interceptor and a torque mod
|
||||
self.torque_mod = True
|
||||
"""
|
||||
|
||||
|
||||
# sanity checks on response messages from vin query
|
||||
def is_vin_response_valid(can_dat, step, cnt):
|
||||
|
||||
can_dat = [ord(i) for i in can_dat]
|
||||
|
||||
if len(can_dat) != 8:
|
||||
# ISO-TP meesages are all 8 bytes
|
||||
return False
|
||||
|
||||
if step == 0:
|
||||
# VIN does not fit in a single message and it's 20 bytes of data
|
||||
if can_dat[0] != 0x10 or can_dat[1] != 0x14:
|
||||
return False
|
||||
|
||||
if step == 1 and cnt == 0:
|
||||
# first response after a CONTINUE query is sent
|
||||
if can_dat[0] != 0x21:
|
||||
return False
|
||||
|
||||
if step == 1 and cnt == 1:
|
||||
# second response after a CONTINUE query is sent
|
||||
if can_dat[0] != 0x22:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import zmq
|
||||
from selfdrive.services import service_list
|
||||
context = zmq.Context()
|
||||
logcan = messaging.sub_sock(context, service_list['can'].port)
|
||||
sendcan = messaging.pub_sock(context, service_list['sendcan'].port)
|
||||
time.sleep(1.) # give time to sendcan socket to start
|
||||
|
||||
print get_vin(logcan, sendcan)
|
||||
Binary file not shown.
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -209,6 +209,7 @@ BO_ 571 WHEEL_BUTTONS: 3 XXX
|
||||
SG_ ACC_FOLLOW_INC : 8|1@0+ (1,0) [0|15] "" XXX
|
||||
SG_ ACC_CANCEL : 0|1@0+ (1,0) [0|15] "" XXX
|
||||
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ ACC_RESUME : 4|1@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
BO_ 669 NEW_MSG_29d: 3 XXX
|
||||
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -196,7 +196,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -260,4 +261,4 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
@@ -142,14 +142,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -50,8 +50,8 @@ BO_ 450 EPB_STATUS: 8 EPB
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON
|
||||
|
||||
BO_ 493 HUD_SETTING: 8 XXX
|
||||
SG_ SPEED_UNIT : 5|1@0+ (1,0) [0|1] "" EON
|
||||
BO_ 493 HUD_SETTING: 5 XXX
|
||||
SG_ IMPERIAL_UNIT : 5|1@0+ (1,0) [0|1] "" EON
|
||||
|
||||
BO_ 487 BRAKE_PRESSURE: 4 VSA
|
||||
SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON
|
||||
@@ -128,7 +128,6 @@ VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_spe
|
||||
VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ;
|
||||
VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ;
|
||||
VAL_ 450 EPB_STATE 3 "engaged" 2 "disengaging" 1 "engaging" 0 "disengaged" ;
|
||||
VAL_ 493 SPEED_UNIT 1 "mph" 0 "kph" ;
|
||||
VAL_ 545 ECON_ON_2 0 "off" 3 "on" ;
|
||||
VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ;
|
||||
VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ;
|
||||
|
||||
@@ -91,7 +91,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
38
opendbc/generator/toyota/lexus_gs300h_2017_pt.dbc
Normal file
38
opendbc/generator/toyota/lexus_gs300h_2017_pt.dbc
Normal file
@@ -0,0 +1,38 @@
|
||||
CM_ "IMPORT _toyota_2017.dbc"
|
||||
CM_ "IMPORT _comma.dbc"
|
||||
|
||||
BO_ 550 BRAKE_MODULE: 8 XXX
|
||||
SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX
|
||||
SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX
|
||||
SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 581 GAS_PEDAL: 5 XXX
|
||||
SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX
|
||||
|
||||
BO_ 608 STEER_TORQUE_SENSOR: 8 XXX
|
||||
SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX
|
||||
SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX
|
||||
SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 610 EPS_STATUS: 5 EPS
|
||||
SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX
|
||||
SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 956 GEAR_PACKET: 8 XXX
|
||||
SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX
|
||||
|
||||
BO_ 1009 PCM_CRUISE_3: 8 XXX
|
||||
SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX
|
||||
SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force";
|
||||
CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8";
|
||||
CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered";
|
||||
CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others";
|
||||
VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled";
|
||||
VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby";
|
||||
VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P";
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_accord_lx15t_2018_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_accord_s2t_2018_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
@@ -288,8 +289,8 @@ BO_ 450 EPB_STATUS: 8 EPB
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON
|
||||
|
||||
BO_ 493 HUD_SETTING: 8 XXX
|
||||
SG_ SPEED_UNIT : 5|1@0+ (1,0) [0|1] "" EON
|
||||
BO_ 493 HUD_SETTING: 5 XXX
|
||||
SG_ IMPERIAL_UNIT : 5|1@0+ (1,0) [0|1] "" EON
|
||||
|
||||
BO_ 487 BRAKE_PRESSURE: 4 VSA
|
||||
SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON
|
||||
@@ -366,7 +367,6 @@ VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_spe
|
||||
VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ;
|
||||
VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ;
|
||||
VAL_ 450 EPB_STATE 3 "engaged" 2 "disengaging" 1 "engaging" 0 "disengaged" ;
|
||||
VAL_ 493 SPEED_UNIT 1 "mph" 0 "kph" ;
|
||||
VAL_ 545 ECON_ON_2 0 "off" 3 "on" ;
|
||||
VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ;
|
||||
VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ;
|
||||
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_crv_ex_2017_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_crv_hybrid_2019_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -200,7 +200,8 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_TO_X3 : 55|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ IMPERIAL_UNIT : 55|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_TO_X1 : 56|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
@@ -265,6 +266,7 @@ BO_ 891 STALK_STATUS_2: 8 XXX
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
|
||||
|
||||
VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ;
|
||||
|
||||
CM_ "honda_insight_ex_2019_can.dbc starts here"
|
||||
|
||||
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
@@ -164,14 +164,15 @@ BO_ 780 ACC_HUD: 8 ADAS
|
||||
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03 : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
|
||||
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X03_2 : 55|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
|
||||
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
|
||||
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
|
||||
|
||||
336
opendbc/lexus_gs300h_2017_pt_generated.dbc
Normal file
336
opendbc/lexus_gs300h_2017_pt_generated.dbc
Normal file
@@ -0,0 +1,336 @@
|
||||
CM_ "AUTOGENERATED FILE, DO NOT EDIT"
|
||||
|
||||
|
||||
CM_ "Imported file _comma.dbc starts here"
|
||||
BO_ 359 STEERING_IPAS_COMMA: 8 IPAS
|
||||
SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX
|
||||
SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant";
|
||||
|
||||
BO_ 512 GAS_COMMAND: 6 EON
|
||||
SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR
|
||||
SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR
|
||||
SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR
|
||||
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR
|
||||
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR
|
||||
|
||||
BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
|
||||
SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON
|
||||
SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON
|
||||
SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON
|
||||
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON
|
||||
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON
|
||||
|
||||
VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;
|
||||
|
||||
|
||||
CM_ "Imported file _toyota_2017.dbc starts here"
|
||||
VERSION ""
|
||||
|
||||
|
||||
NS_ :
|
||||
NS_DESC_
|
||||
CM_
|
||||
BA_DEF_
|
||||
BA_
|
||||
VAL_
|
||||
CAT_DEF_
|
||||
CAT_
|
||||
FILTER
|
||||
BA_DEF_DEF_
|
||||
EV_DATA_
|
||||
ENVVAR_DATA_
|
||||
SGTYPE_
|
||||
SGTYPE_VAL_
|
||||
BA_DEF_SGTYPE_
|
||||
BA_SGTYPE_
|
||||
SIG_TYPE_REF_
|
||||
VAL_TABLE_
|
||||
SIG_GROUP_
|
||||
SIG_VALTYPE_
|
||||
SIGTYPE_VALTYPE_
|
||||
BO_TX_BU_
|
||||
BA_DEF_REL_
|
||||
BA_REL_
|
||||
BA_DEF_DEF_REL_
|
||||
BU_SG_REL_
|
||||
BU_EV_REL_
|
||||
BU_BO_REL_
|
||||
SG_MUL_VAL_
|
||||
|
||||
BS_:
|
||||
|
||||
BU_: XXX DSU HCU EPS IPAS
|
||||
|
||||
BO_ 36 KINEMATICS: 8 XXX
|
||||
SG_ ACCEL_Y : 33|10@0+ (1,-512) [0|65535] "" XXX
|
||||
SG_ YAW_RATE : 1|10@0+ (1,-512) [0|65535] "" XXX
|
||||
SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX
|
||||
|
||||
BO_ 37 STEER_ANGLE_SENSOR: 8 XXX
|
||||
SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX
|
||||
SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX
|
||||
SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX
|
||||
|
||||
BO_ 166 BRAKE: 8 XXX
|
||||
SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 170 WHEEL_SPEEDS: 8 XXX
|
||||
SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX
|
||||
SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX
|
||||
SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX
|
||||
SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX
|
||||
|
||||
BO_ 180 SPEED: 8 XXX
|
||||
SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX
|
||||
|
||||
BO_ 353 DSU_SPEED: 8 XXX
|
||||
SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX
|
||||
|
||||
BO_ 466 PCM_CRUISE: 8 XXX
|
||||
SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX
|
||||
SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 467 PCM_CRUISE_2: 8 XXX
|
||||
SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX
|
||||
SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 552 ACCELEROMETER: 8 XXX
|
||||
SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX
|
||||
SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX
|
||||
|
||||
BO_ 560 BRAKE_MODULE2: 7 XXX
|
||||
SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX
|
||||
SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
BO_ 740 STEERING_LKA: 5 XXX
|
||||
SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX
|
||||
SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX
|
||||
SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 742 LEAD_INFO: 8 DSU
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU
|
||||
SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU
|
||||
SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU
|
||||
|
||||
BO_ 835 ACC_CONTROL: 8 DSU
|
||||
SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU
|
||||
SG_ SET_ME_X01 : 23|2@0+ (1,0) [0|3] "" HCU
|
||||
SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ SET_ME_1 : 30|1@0+ (1,0) [0|1] "" HCU
|
||||
SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU
|
||||
SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 921 PCM_CRUISE_SM: 8 XXX
|
||||
SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 951 ESP_CONTROL: 8 ESP
|
||||
SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 1041 ACC_HUD: 8 DSU
|
||||
SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 1042 LKAS_HUD: 8 XXX
|
||||
SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX
|
||||
SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 1553 UI_SEETING: 8 XXX
|
||||
SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 1556 STEERING_LEVERS: 8 XXX
|
||||
SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 1568 SEATS_DOORS: 8 XXX
|
||||
SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 1570 LIGHT_STALK: 8 SCM
|
||||
SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 1161 RSA1: 8 FCM
|
||||
SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX
|
||||
SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX
|
||||
SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX
|
||||
|
||||
BO_ 1162 RSA2: 8 FCM
|
||||
SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX
|
||||
|
||||
BO_ 1163 RSA3: 8 FCM
|
||||
SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX
|
||||
SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX
|
||||
SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX
|
||||
SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX
|
||||
SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX
|
||||
SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX
|
||||
SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX
|
||||
|
||||
CM_ SG_ 36 ACCEL_Y "unit is tbd";
|
||||
CM_ SG_ 36 YAW_RATE "verify";
|
||||
CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd";
|
||||
CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set";
|
||||
CM_ SG_ 37 STEER_RATE "factor is tbd";
|
||||
CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors";
|
||||
CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isnt perfect";
|
||||
CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph";
|
||||
CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?";
|
||||
CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque";
|
||||
CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value";
|
||||
CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active";
|
||||
CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit";
|
||||
CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel";
|
||||
CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces";
|
||||
CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts";
|
||||
CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit.";
|
||||
CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz";
|
||||
CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"
|
||||
CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0";
|
||||
CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz";
|
||||
CM_ SG_ 1163 TSREQPD "always 1";
|
||||
CM_ SG_ 1163 TSRMSW "always 1";
|
||||
CM_ SG_ 1163 OTSGNNTM "always 3";
|
||||
CM_ SG_ 1163 NTLVLSPD "always 3";
|
||||
CM_ SG_ 1163 OVSPNTM "always 3";
|
||||
CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds";
|
||||
CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds";
|
||||
CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds";
|
||||
CM_ SG_ 1163 TSRSPU "always 1";
|
||||
|
||||
VAL_ 466 CRUISE_STATE 8 "active" 7 "standstill" 1 "off";
|
||||
VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok";
|
||||
VAL_ 614 STATE 3 "enabled" 1 "disabled";
|
||||
VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left";
|
||||
VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted";
|
||||
VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none";
|
||||
VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none";
|
||||
VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none";
|
||||
VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none";
|
||||
VAL_ 1553 UNITS 1 "km" 2 "miles";
|
||||
VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left";
|
||||
VAL_ 1161 TSGN1 1 "speed sign" 0 "none";
|
||||
VAL_ 1161 TSGN2 1 "speed sign" 0 "none";
|
||||
VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none";
|
||||
VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 129 "no entry";
|
||||
VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none";
|
||||
|
||||
|
||||
CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180";
|
||||
|
||||
CM_ "lexus_gs300h_2017_pt.dbc starts here"
|
||||
|
||||
|
||||
|
||||
BO_ 550 BRAKE_MODULE: 8 XXX
|
||||
SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX
|
||||
SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX
|
||||
SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 581 GAS_PEDAL: 5 XXX
|
||||
SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX
|
||||
|
||||
BO_ 608 STEER_TORQUE_SENSOR: 8 XXX
|
||||
SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX
|
||||
SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX
|
||||
SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 610 EPS_STATUS: 5 EPS
|
||||
SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX
|
||||
SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX
|
||||
SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 956 GEAR_PACKET: 8 XXX
|
||||
SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX
|
||||
|
||||
BO_ 1009 PCM_CRUISE_3: 8 XXX
|
||||
SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX
|
||||
SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|15] "" XXX
|
||||
|
||||
CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force";
|
||||
CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8";
|
||||
CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered";
|
||||
CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others";
|
||||
VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled";
|
||||
VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby";
|
||||
VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P";
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -225,7 +225,11 @@ BO_ 802 ES_LKAS_State: 8 XXX
|
||||
SG_ LKAS_ENABLE_3 : 24|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Signal3 : 25|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ LKAS_ENABLE_2 : 26|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Signal4 : 27|5@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Signal4 : 27|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ LKAS_Left_Line_Visible : 28|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Signal6 : 29|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ LKAS_Right_Line_Visible : 30|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Signal7 : 31|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ FCW_Cont_Beep : 32|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ FCW_Repeated_Beep : 33|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ Throttle_Management_Activated : 34|1@1+ (1,0) [0|1] "" XXX
|
||||
@@ -321,10 +325,11 @@ BO_ 1658 NEW_MSG_39: 8 XXX
|
||||
SG_ NEW_SIGNAL_3 : 33|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 1677 NEW_MSG_40: 8 XXX
|
||||
BO_ 1677 Dash_State: 8 XXX
|
||||
SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX
|
||||
SG_ NEW_SIGNAL_3 : 16|4@1+ (1,0) [0|15] "" XXX
|
||||
SG_ Units : 29|3@1+ (1,0) [0|7] "" XXX
|
||||
|
||||
BO_ 1743 NEW_MSG_41: 8 XXX
|
||||
SG_ Checksum : 0|8@1+ (1,0) [0|255] "" XXX
|
||||
@@ -355,3 +360,4 @@ CM_ SG_ 940 FOG_LIGHTS2 "yellow fog light in the dash";
|
||||
CM_ SG_ 940 Highbeam "01 = low beam, 11 = high beam";
|
||||
CM_ SG_ 805 NEW_SIGNAL_3 "always 3";
|
||||
CM_ SG_ 805 NEW_SIGNAL_4 "always 1";
|
||||
CM_ SG_ 1677 Units "1 = imperial, 6 = metric";
|
||||
|
||||
@@ -38,11 +38,11 @@ BU_: XXX
|
||||
|
||||
BO_ 2 Steering: 8 XXX
|
||||
SG_ NEW_SIGNAL_1 : 31|4@0- (1,0) [0|65535] "" XXX
|
||||
SG_ NEW_SIGNAL_6 : 24|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Counter : 25|3@1+ (1,0) [0|15] "" XXX
|
||||
SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ NEW_SIGNAL_2 : 22|3@0+ (1,0) [0|7] "" XXX
|
||||
SG_ Steering_Angle : 7|16@0- (-0.1,-9) [-497|500] "degree" XXX
|
||||
SG_ NEW_SIGNAL_6 : 24|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX
|
||||
|
||||
BO_ 208 G_Sensor: 8 XXX
|
||||
SG_ NEW_SIGNAL_3 : 32|8@1+ (1,0) [0|255] "" XXX
|
||||
@@ -52,10 +52,9 @@ BO_ 208 G_Sensor: 8 XXX
|
||||
SG_ _Longitudinal : 48|16@1- (0.000035,0) [0|255] "" XXX
|
||||
|
||||
BO_ 209 Brake_Pedal: 8 XXX
|
||||
SG_ NEW_SIGNAL_2 : 31|1@1+ (1,0) [0|255] "" XXX
|
||||
SG_ NEW_SIGNAL_3 : 56|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ NEW_SIGNAL_1 : 26|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Brake_Pedal : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ NEW_SIGNAL_2 : 31|1@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX
|
||||
|
||||
BO_ 210 Brake_2: 8 XXX
|
||||
@@ -76,7 +75,7 @@ BO_ 211 Brake_Type: 8 XXX
|
||||
SG_ Brake_Cruise_On : 42|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Brake_Pedal_On : 46|1@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 212 WHEEL_SPEEDS: 8 XXX
|
||||
BO_ 212 Wheel_Speeds: 8 XXX
|
||||
SG_ FL : 0|16@1+ (0.0592,0) [2|255] "KPH" XXX
|
||||
SG_ FR : 16|16@1+ (0.0592,0) [0|255] "KPH" XXX
|
||||
SG_ RL : 32|16@1+ (0.0592,0) [0|255] "" XXX
|
||||
@@ -106,7 +105,7 @@ BO_ 321 undefined: 8 XXX
|
||||
SG_ Wheel_Torque : 16|12@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Engine_Stop : 15|1@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 324 CruiseControl_2015: 8 XXX
|
||||
BO_ 324 CruiseControl: 8 XXX
|
||||
SG_ Cruise_On : 48|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ OnOffButton : 2|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_BUTTON : 3|1@0+ (1,0) [0|3] "" XXX
|
||||
@@ -117,8 +116,8 @@ BO_ 324 CruiseControl_2015: 8 XXX
|
||||
SG_ NEW_SIGNAL_2 : 8|1@0+ (1,0) [0|255] "" XXX
|
||||
SG_ Cruise_Activated : 49|1@0+ (1,0) [0|7] "" XXX
|
||||
SG_ Brake_Pedal_On : 51|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Button : 13|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ NEW_SIGNAL_1 : 23|8@0+ (1,-124) [0|255] "" XXX
|
||||
SG_ Button : 13|1@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 328 Transmission: 8 XXX
|
||||
SG_ Counter : 11|4@0+ (1,0) [0|255] "" XXX
|
||||
@@ -165,6 +164,7 @@ BO_ 352 ES_Brake: 8 XXX
|
||||
SG_ Brake_Light : 20|1@0+ (1,0) [0|2047] "" XXX
|
||||
SG_ Cruise_Activated : 23|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX
|
||||
SG_ ES_Error : 21|1@0+ (1,0) [0|7] "" XXX
|
||||
|
||||
BO_ 353 ES_CruiseThrottle: 8 XXX
|
||||
SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|255] "" XXX
|
||||
@@ -182,6 +182,7 @@ BO_ 353 ES_CruiseThrottle: 8 XXX
|
||||
SG_ NEW_SIGNAL_6_Blank : 23|1@0+ (1,0) [0|7] "" XXX
|
||||
SG_ DistanceSwap : 21|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Brake_On : 20|1@0+ (1,0) [0|7] "" XXX
|
||||
SG_ ES_Error : 42|1@1+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 354 ES_RPM: 8 XXX
|
||||
SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX
|
||||
@@ -192,17 +193,14 @@ BO_ 354 ES_RPM: 8 XXX
|
||||
|
||||
BO_ 356 ES_LKAS: 8 XXX
|
||||
SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Counter : 0|3@1+ (1,0) [0|8] "" XXX
|
||||
SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX
|
||||
SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX
|
||||
SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4095] "" XXX
|
||||
SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX
|
||||
|
||||
BO_ 358 ES_Status: 8 XXX
|
||||
BO_ 358 ES_DashStatus: 8 XXX
|
||||
SG_ Counter : 39|3@0+ (1,0) [0|7] "" XXX
|
||||
SG_ Cruise_On : 16|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Cruise_Activated : 17|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Obstacle_Distance : 48|4@1+ (1,0) [0|15] "" XXX
|
||||
SG_ Cruise_Off : 22|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Saved_Speed : 24|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Car_Follow : 46|1@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Driver_Input : 20|1@0+ (1,0) [0|15] "" XXX
|
||||
SG_ WHEELS_MOVING_2015 : 19|1@1+ (1,0) [0|3] "" XXX
|
||||
@@ -211,24 +209,28 @@ BO_ 358 ES_Status: 8 XXX
|
||||
SG_ NEW_SIGNAL_5_Blank : 33|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ NEW_SIGNAL_4_Blank : 34|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ NEW_SIGNAL_1 : 35|1@0+ (1,0) [0|31] "" XXX
|
||||
SG_ Sig3SecondDisengage : 13|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Steep_Hill_Disengage : 44|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ ES_Error : 32|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Cruise_Activated : 17|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Cruise_On : 16|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Disengage_Alert : 15|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ 3SecondDisengage : 13|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 359 ES_LDW: 8 XXX
|
||||
SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Sig2All_Depart : 28|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig3All_Depart : 52|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Left_Depart_Front : 51|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ All_depart_2015 : 0|1@1+ (1,0) [0|255] "" XXX
|
||||
SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ LKAS_Steer_Active_2017 : 37|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig2All_Depart : 28|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig1All_Depart : 31|1@0+ (1,0) [0|15] "" XXX
|
||||
SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|7] "" XXX
|
||||
SG_ Left_Depart_Front : 51|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ Sig3All_Depart : 52|1@0+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 392 Counter_0: 8 XXX
|
||||
SG_ Counter : 16|4@1+ (1,0) [0|15] "" XXX
|
||||
@@ -255,6 +257,7 @@ BO_ 642 Dashlights: 8 XXX
|
||||
SG_ NEW_SIGNAL_3 : 34|2@1+ (1,0) [0|3] "" XXX
|
||||
SG_ LEFT_BLINKER : 44|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ RIGHT_BLINKER : 45|1@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|3] "" XXX
|
||||
|
||||
BO_ 644 NEW_MSG_8: 8 XXX
|
||||
SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX
|
||||
@@ -272,21 +275,23 @@ BO_ 880 Steer_Torque_2: 8 XXX
|
||||
SG_ Steer_Torque_Sensor : 32|8@1- (-1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 881 Steering_Torque: 8 XXX
|
||||
SG_ Steering_Motor_Flat : 0|8@1+ (1,0) [0|255] "" XXX
|
||||
SG_ Steer_Torque_Sensor : 39|8@0- (1,0) [0|255] "" XXX
|
||||
SG_ Steering_Angle : 40|16@1- (-0.026,0) [0|255] "" XXX
|
||||
SG_ Steering_Motor_LeftRight : 23|16@0- (-0.13,0) [0|255] "" XXX
|
||||
SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|16500] "" XXX
|
||||
SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-16500|16500] "" XXX
|
||||
SG_ Steer_Torque_Sensor : 29|11@1- (8,0) [-8500|-8500] "" XXX
|
||||
SG_ Steering_Angle : 40|16@1- (-0.026,0) [-600|600] "" XXX
|
||||
SG_ LKA_Lockout : 27|1@1+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 882 Counter: 8 XXX
|
||||
SG_ Counter : 15|4@0+ (1,0) [0|31] "" XXX
|
||||
SG_ Something : 16|2@1+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 884 DOORS_STATUS: 8 XXX
|
||||
BO_ 884 BodyInfo: 8 XXX
|
||||
SG_ DOOR_OPEN_FR : 24|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_FL : 25|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_RL : 26|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_RR : 27|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ DOOR_OPEN_Hatch : 28|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ _UNKNOWN : 2|3@0+ (1,0) [0|1] "" XXX
|
||||
|
||||
BO_ 886 undefined: 8 XXX
|
||||
|
||||
@@ -341,30 +346,27 @@ CM_ SG_ 320 Off_Throttle_2 "Less sensitive";
|
||||
CM_ SG_ 320 Throttle_Body_ "Throttle related";
|
||||
CM_ SG_ 328 Gear "15 = P, 14 = R, 0 = N, 1-6=gear";
|
||||
CM_ SG_ 328 Gear_2 "15 = P, 14 = R, 0 = N, 1-6=gear";
|
||||
CM_ SG_ 338 Wiper "0 off, 1 on";
|
||||
CM_ SG_ 353 NEW_SIGNAL_3_Blank "always 2";
|
||||
CM_ SG_ 353 NEW_SIGNAL_2_Blank "0";
|
||||
CM_ SG_ 353 NEW_SIGNAL_9 "flipped around quick engagement";
|
||||
CM_ SG_ 353 NEW_SIGNAL_6_Blank "always 1";
|
||||
CM_ SG_ 353 Brake_On "long activatedish";
|
||||
CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission";
|
||||
CM_ SG_ 358 Cruise_Activated "is 1 when cruise is able to go";
|
||||
CM_ SG_ 358 Car_Follow "front car detected";
|
||||
CM_ SG_ 358 Sig3SecondDisengage "seatbelt disengage";
|
||||
CM_ SG_ 358 ES_Error "No engagement until restart";
|
||||
CM_ SG_ 358 Cruise_Activated "is 1 when cruise is able to go";
|
||||
CM_ SG_ 358 Disengage_Alert "seatbelt and steep hill disengage";
|
||||
CM_ SG_ 359 Sig2All_Depart "Left and right depart";
|
||||
CM_ SG_ 359 Left_Depart_Front "warning after acceleration into car in front and left depart";
|
||||
CM_ SG_ 358 3SecondDisengage "seatbelt disengage";
|
||||
CM_ SG_ 359 All_depart_2015 "always 1 on 2017";
|
||||
CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering";
|
||||
CM_ SG_ 359 Sig2All_Depart "Left and right depart";
|
||||
CM_ SG_ 359 Sig1All_Depart "Left and right depart";
|
||||
CM_ SG_ 359 Sig1Right_Depart_Front "object in front, right depart, hill steep and seatbelt disengage alert ";
|
||||
CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage";
|
||||
CM_ SG_ 359 Sig1Right_Depart_Front "object in front, right depart, hill steep and seatbelt disengage alert ";
|
||||
CM_ SG_ 359 Left_Depart_Front "warning after acceleration into car in front and left depart";
|
||||
CM_ SG_ 642 Counter "Affected by signals";
|
||||
CM_ SG_ 642 RIGHT_BLINKER "0 off, 2 right, 1 left";
|
||||
CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371";
|
||||
CM_ SG_ 880 NEW_SIGNAL_1 "0 in 2017";
|
||||
CM_ SG_ 880 NEW_SIGNAL_2 "";
|
||||
CM_ SG_ 880 NEW_SIGNAL_4_2017 "1 in 2017";
|
||||
CM_ SG_ 880 NEW_SIGNAL_5_2017 "1 in 2017";
|
||||
CM_ SG_ 881 Steering_Motor_Flat "Possibly motor voltage";
|
||||
CM_ SG_ 881 Steering_Angle "Missing extra larger bits";
|
||||
|
||||
1371
opendbc/tesla_radar.dbc
Normal file
1371
opendbc/tesla_radar.dbc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
285
opendbc/toyota_rav4_2019_adas.dbc
Normal file
285
opendbc/toyota_rav4_2019_adas.dbc
Normal file
@@ -0,0 +1,285 @@
|
||||
VERSION ""
|
||||
|
||||
|
||||
NS_ :
|
||||
NS_DESC_
|
||||
CM_
|
||||
BA_DEF_
|
||||
BA_
|
||||
VAL_
|
||||
CAT_DEF_
|
||||
CAT_
|
||||
FILTER
|
||||
BA_DEF_DEF_
|
||||
EV_DATA_
|
||||
ENVVAR_DATA_
|
||||
SGTYPE_
|
||||
SGTYPE_VAL_
|
||||
BA_DEF_SGTYPE_
|
||||
BA_SGTYPE_
|
||||
SIG_TYPE_REF_
|
||||
VAL_TABLE_
|
||||
SIG_GROUP_
|
||||
SIG_VALTYPE_
|
||||
SIGTYPE_VALTYPE_
|
||||
BO_TX_BU_
|
||||
BA_DEF_REL_
|
||||
BA_REL_
|
||||
BA_DEF_DEF_REL_
|
||||
BU_SG_REL_
|
||||
BU_EV_REL_
|
||||
BU_BO_REL_
|
||||
SG_MUL_VAL_
|
||||
|
||||
BS_:
|
||||
|
||||
BU_: XXX
|
||||
|
||||
|
||||
BO_ 384 TRACK_A_0: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 385 TRACK_A_1: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 386 TRACK_A_2: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 387 TRACK_A_3: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 388 TRACK_A_4: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 389 TRACK_A_5: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 390 TRACK_A_6: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 391 TRACK_A_7: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 392 TRACK_A_8: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 393 TRACK_A_9: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 394 TRACK_A_10: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 395 TRACK_A_11: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 396 TRACK_A_12: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 397 TRACK_A_13: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 398 TRACK_A_14: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 399 TRACK_A_15: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX
|
||||
SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX
|
||||
SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX
|
||||
SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 400 TRACK_B_0: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 401 TRACK_B_1: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 402 TRACK_B_2: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 403 TRACK_B_3: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 404 TRACK_B_4: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 405 TRACK_B_5: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 406 TRACK_B_6: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 407 TRACK_B_7: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 408 TRACK_B_8: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 409 TRACK_B_9: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 410 TRACK_B_10: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 411 TRACK_B_11: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 412 TRACK_B_12: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 413 TRACK_B_13: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 414 TRACK_B_14: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 415 TRACK_B_15: 8 XXX
|
||||
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
|
||||
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 576 NEW_MSG_1: 8 XXX
|
||||
SG_ NEW_SIGNAL_1 : 15|7@0+ (1,0) [0|127] "" XXX
|
||||
SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 577 NEW_MSG_2: 8 XXX
|
||||
SG_ NEW_SIGNAL_1 : 15|7@0+ (1,0) [0|127] "" XXX
|
||||
SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
@@ -125,7 +125,7 @@ BO_ 614 STEERING_IPAS: 8 IPAS
|
||||
SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX
|
||||
SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX
|
||||
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
|
||||
|
||||
BO_ 643 PRE_COLLISION: 8 XXX
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,37 @@ jobs:
|
||||
name: Run safety test
|
||||
command: |
|
||||
docker run panda_safety /bin/bash -c "cd /panda/tests/safety; ./test.sh"
|
||||
|
||||
misra-c2012:
|
||||
machine:
|
||||
docker_layer_caching: true
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Build image
|
||||
command: "docker build -t panda_misra -f tests/misra/Dockerfile ."
|
||||
- run:
|
||||
name: Run Misra C 2012 test
|
||||
command: |
|
||||
mkdir /tmp/misra
|
||||
docker run -v /tmp/misra:/tmp/misra panda_misra /bin/bash -c "cd /panda/tests/misra; ./test_misra.sh"
|
||||
- store_artifacts:
|
||||
name: Store misra test output
|
||||
path: /tmp/misra/output.txt
|
||||
|
||||
strict-compiler:
|
||||
machine:
|
||||
docker_layer_caching: true
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Build image
|
||||
command: "docker build -t panda_strict_compiler -f tests/build_strict/Dockerfile ."
|
||||
- run:
|
||||
name: Build Panda with strict compiler rules
|
||||
command: |
|
||||
docker run panda_strict_compiler /bin/bash -c "cd /panda/board; make -f Makefile.strict clean; make -f Makefile.strict bin"
|
||||
|
||||
build:
|
||||
machine:
|
||||
docker_layer_caching: true
|
||||
@@ -40,10 +71,6 @@ jobs:
|
||||
name: Build Pedal STM bootstub image
|
||||
command: |
|
||||
docker run panda_build /bin/bash -c "cd /panda/board/pedal; make obj/bootstub.bin"
|
||||
- run:
|
||||
name: Build NEO STM image
|
||||
command: |
|
||||
docker run panda_build /bin/bash -c "cd /panda/board; make clean; make -f Makefile.legacy obj/comma.bin"
|
||||
- run:
|
||||
name: Build ESP image
|
||||
command: |
|
||||
@@ -54,4 +81,6 @@ workflows:
|
||||
main:
|
||||
jobs:
|
||||
- safety
|
||||
- misra-c2012
|
||||
- strict-compiler
|
||||
- build
|
||||
|
||||
5
panda/.gitignore
vendored
5
panda/.gitignore
vendored
@@ -10,5 +10,6 @@ a.out
|
||||
dist/
|
||||
pandacan.egg-info/
|
||||
board/obj/
|
||||
examples/output.csv
|
||||
.DS_Store
|
||||
examples/output.csv
|
||||
.DS_Store
|
||||
nosetests.xml
|
||||
|
||||
@@ -59,6 +59,4 @@ USER pandauser
|
||||
RUN cd /tmp/panda/boardesp && ./get_sdk_ci.sh
|
||||
USER root
|
||||
|
||||
COPY ./xx/pandaextra /tmp/pandaextra
|
||||
|
||||
ADD ./panda.tar.gz /tmp/panda
|
||||
|
||||
6
panda/Jenkinsfile
vendored
6
panda/Jenkinsfile
vendored
@@ -6,16 +6,14 @@ pipeline {
|
||||
script: "git --no-pager show -s --format='%an' ${GIT_COMMIT}"
|
||||
).trim()}"""
|
||||
|
||||
DOCKER_IMAGE_TAG = "panda:build-${env.BUILD_ID}"
|
||||
DOCKER_NAME = "panda-test-${env.BUILD_ID}"
|
||||
DOCKER_IMAGE_TAG = "panda:build-${env.GIT_COMMIT}"
|
||||
DOCKER_NAME = "panda-test-${env.GIT_COMMIT}"
|
||||
}
|
||||
stages {
|
||||
stage('Build Docker Image') {
|
||||
steps {
|
||||
timeout(time: 60, unit: 'MINUTES') {
|
||||
script {
|
||||
sh 'git clone --no-checkout --depth 1 git@github.com:commaai/xx.git || true'
|
||||
sh 'cd xx && git fetch origin && git checkout origin/master -- pandaextra && cd ..' // Needed for certs for panda flashing
|
||||
sh 'git archive -v -o panda.tar.gz --format=tar.gz HEAD'
|
||||
dockerImage = docker.build("${env.DOCKER_IMAGE_TAG}")
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
v1.2.1
|
||||
v1.3.1
|
||||
@@ -1,9 +0,0 @@
|
||||
# :set noet
|
||||
PROJ_NAME = comma
|
||||
CFLAGS = -g -Wall
|
||||
|
||||
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3
|
||||
CFLAGS += -msoft-float -DSTM32F2 -DSTM32F205xx
|
||||
STARTUP_FILE = startup_stm32f205xx
|
||||
|
||||
include build.mk
|
||||
8
panda/board/Makefile.strict
Normal file
8
panda/board/Makefile.strict
Normal file
@@ -0,0 +1,8 @@
|
||||
PROJ_NAME = panda
|
||||
CFLAGS = -g -Wall -Wextra -pedantic -Wstrict-prototypes
|
||||
|
||||
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4
|
||||
CFLAGS += -mhard-float -DSTM32F4 -DSTM32F413xx -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
||||
STARTUP_FILE = startup_stm32f413xx
|
||||
|
||||
include build.mk
|
||||
@@ -23,12 +23,6 @@ Programming
|
||||
make
|
||||
```
|
||||
|
||||
**NEO**
|
||||
|
||||
```
|
||||
make -f Makefile.legacy
|
||||
```
|
||||
|
||||
Troubleshooting
|
||||
----
|
||||
|
||||
|
||||
@@ -12,11 +12,14 @@
|
||||
#include "stm32f2xx_hal_gpio_ex.h"
|
||||
#endif
|
||||
|
||||
// default since there's no serial
|
||||
int puts(const char *a) { return 0; }
|
||||
void puth(unsigned int i) {}
|
||||
|
||||
#include "libc.h"
|
||||
#include "provision.h"
|
||||
|
||||
#include "drivers/drivers.h"
|
||||
|
||||
#include "drivers/clock.h"
|
||||
#include "drivers/llgpio.h"
|
||||
#include "gpio.h"
|
||||
|
||||
@@ -24,15 +27,6 @@
|
||||
#include "drivers/usb.h"
|
||||
//#include "drivers/uart.h"
|
||||
|
||||
#ifdef PEDAL
|
||||
#define CUSTOM_CAN_INTERRUPTS
|
||||
#include "safety.h"
|
||||
#include "drivers/can.h"
|
||||
#endif
|
||||
|
||||
int puts(const char *a) { return 0; }
|
||||
void puth(unsigned int i) {}
|
||||
|
||||
#include "crypto/rsa.h"
|
||||
#include "crypto/sha.h"
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ endif
|
||||
|
||||
DFU_UTIL = "dfu-util"
|
||||
|
||||
DEPDIR = generated_dependencies
|
||||
$(shell mkdir -p -m 777 $(DEPDIR) >/dev/null)
|
||||
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
|
||||
POSTCOMPILE = @mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
|
||||
|
||||
# this no longer pushes the bootstub
|
||||
flash: obj/$(PROJ_NAME).bin
|
||||
PYTHONPATH=../ python -c "from python import Panda; Panda().flash('obj/$(PROJ_NAME).bin')"
|
||||
@@ -45,8 +50,9 @@ include ../common/version.mk
|
||||
obj/cert.h: ../crypto/getcertheader.py
|
||||
../crypto/getcertheader.py ../certs/debug.pub ../certs/release.pub > $@
|
||||
|
||||
obj/%.$(PROJ_NAME).o: %.c obj/cert.h obj/gitversion.h config.h drivers/*.h gpio.h libc.h provision.h safety.h safety/*.h spi_flasher.h
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
obj/%.$(PROJ_NAME).o: %.c obj/gitversion.h obj/cert.h $(DEPDIR)/%.d
|
||||
$(CC) $(DEPFLAGS) $(CFLAGS) -o $@ -c $<
|
||||
$(POSTCOMPILE)
|
||||
|
||||
obj/%.$(PROJ_NAME).o: ../crypto/%.c
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
@@ -59,12 +65,18 @@ obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).o
|
||||
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
|
||||
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
|
||||
SETLEN=1 ../crypto/sign.py obj/code.bin $@ $(CERT)
|
||||
@BINSIZE=$$(du -b "obj/$(PROJ_NAME).bin" | cut -f 1) ; if [ $$BINSIZE -ge 32768 ]; then echo "ERROR obj/$(PROJ_NAME).bin is too big!"; exit 1; fi;
|
||||
|
||||
@BINSIZE=$$(du -b "obj/$(PROJ_NAME).bin" | cut -f 1) ; \
|
||||
if [ $$BINSIZE -ge 32768 ]; then echo "ERROR obj/$(PROJ_NAME).bin is too big!"; exit 1; fi;
|
||||
|
||||
obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.$(PROJ_NAME).o obj/rsa.$(PROJ_NAME).o
|
||||
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
|
||||
$(OBJCOPY) -v -O binary obj/bootstub.$(PROJ_NAME).elf $@
|
||||
|
||||
$(DEPDIR)/%.d: ;
|
||||
.PRECIOUS: $(DEPDIR)/%.d
|
||||
|
||||
include $(wildcard $(patsubst %,$(DEPDIR)/%.d,$(basename $(wildcard *.c))))
|
||||
|
||||
clean:
|
||||
@rm -f obj/*
|
||||
@$(RM) obj/*
|
||||
@rm -rf $(DEPDIR)
|
||||
|
||||
@@ -1,10 +1,38 @@
|
||||
// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE, CAN2_TX, CAN2_RX0, CAN2_SCE, CAN3_TX, CAN3_RX0, CAN3_SCE
|
||||
// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE
|
||||
// CAN2_TX, CAN2_RX0, CAN2_SCE
|
||||
// CAN3_TX, CAN3_RX0, CAN3_SCE
|
||||
|
||||
typedef struct {
|
||||
uint32_t w_ptr;
|
||||
uint32_t r_ptr;
|
||||
uint32_t fifo_size;
|
||||
CAN_FIFOMailBox_TypeDef *elems;
|
||||
} can_ring;
|
||||
|
||||
#define CAN_BUS_RET_FLAG 0x80
|
||||
#define CAN_BUS_NUM_MASK 0x7F
|
||||
|
||||
#define BUS_MAX 4
|
||||
|
||||
extern int can_live, pending_can_live;
|
||||
|
||||
// must reinit after changing these
|
||||
extern int can_loopback, can_silent;
|
||||
extern uint32_t can_speed[];
|
||||
|
||||
void can_set_forwarding(int from, int to);
|
||||
|
||||
void can_init(uint8_t can_number);
|
||||
void can_init_all();
|
||||
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number);
|
||||
int can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem);
|
||||
|
||||
// end API
|
||||
|
||||
#define ALL_CAN_SILENT 0xFF
|
||||
#define ALL_CAN_BUT_MAIN_SILENT 0xFE
|
||||
#define ALL_CAN_LIVE 0
|
||||
|
||||
#include "lline_relay.h"
|
||||
|
||||
int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = ALL_CAN_SILENT;
|
||||
|
||||
// ********************* instantiate queues *********************
|
||||
@@ -16,19 +44,9 @@ int can_live = 0, pending_can_live = 0, can_loopback = 0, can_silent = ALL_CAN_S
|
||||
can_buffer(rx_q, 0x1000)
|
||||
can_buffer(tx1_q, 0x100)
|
||||
can_buffer(tx2_q, 0x100)
|
||||
|
||||
#ifdef PANDA
|
||||
can_buffer(tx3_q, 0x100)
|
||||
can_buffer(txgmlan_q, 0x100)
|
||||
can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q};
|
||||
#else
|
||||
can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q};
|
||||
#endif
|
||||
|
||||
#ifdef PANDA
|
||||
// Forward declare
|
||||
void power_save_reset_timer();
|
||||
#endif
|
||||
can_buffer(tx3_q, 0x100)
|
||||
can_buffer(txgmlan_q, 0x100)
|
||||
can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q};
|
||||
|
||||
// ********************* interrupt safe queue *********************
|
||||
|
||||
@@ -85,76 +103,20 @@ int can_tx_cnt = 0;
|
||||
int can_txd_cnt = 0;
|
||||
int can_err_cnt = 0;
|
||||
|
||||
// NEO: Bus 1=CAN1 Bus 2=CAN2
|
||||
// Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3
|
||||
#ifdef PANDA
|
||||
CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3};
|
||||
uint8_t bus_lookup[] = {0,1,2};
|
||||
uint8_t can_num_lookup[] = {0,1,2,-1};
|
||||
int8_t can_forwarding[] = {-1,-1,-1,-1};
|
||||
uint32_t can_speed[] = {5000, 5000, 5000, 333};
|
||||
bool can_autobaud_enabled[] = {false, false, false, false};
|
||||
#define CAN_MAX 3
|
||||
#else
|
||||
CAN_TypeDef *cans[] = {CAN1, CAN2};
|
||||
uint8_t bus_lookup[] = {1,0};
|
||||
uint8_t can_num_lookup[] = {1,0};
|
||||
int8_t can_forwarding[] = {-1,-1};
|
||||
uint32_t can_speed[] = {5000, 5000};
|
||||
bool can_autobaud_enabled[] = {false, false};
|
||||
#define CAN_MAX 2
|
||||
#endif
|
||||
|
||||
uint32_t can_autobaud_speeds[] = {5000, 2500, 1250, 1000, 10000};
|
||||
#define AUTOBAUD_SPEEDS_LEN (sizeof(can_autobaud_speeds) / sizeof(can_autobaud_speeds[0]))
|
||||
CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3};
|
||||
uint8_t bus_lookup[] = {0,1,2};
|
||||
uint8_t can_num_lookup[] = {0,1,2,-1};
|
||||
int8_t can_forwarding[] = {-1,-1,-1,-1};
|
||||
uint32_t can_speed[] = {5000, 5000, 5000, 333};
|
||||
#define CAN_MAX 3
|
||||
|
||||
#define CANIF_FROM_CAN_NUM(num) (cans[num])
|
||||
#ifdef PANDA
|
||||
#define CAN_NUM_FROM_CANIF(CAN) (CAN==CAN1 ? 0 : (CAN==CAN2 ? 1 : 2))
|
||||
#define CAN_NAME_FROM_CANIF(CAN) (CAN==CAN1 ? "CAN1" : (CAN==CAN2 ? "CAN2" : "CAN3"))
|
||||
#else
|
||||
#define CAN_NUM_FROM_CANIF(CAN) (CAN==CAN1 ? 0 : 1)
|
||||
#define CAN_NAME_FROM_CANIF(CAN) (CAN==CAN1 ? "CAN1" : "CAN2")
|
||||
#endif
|
||||
#define BUS_NUM_FROM_CAN_NUM(num) (bus_lookup[num])
|
||||
#define CAN_NUM_FROM_BUS_NUM(num) (can_num_lookup[num])
|
||||
|
||||
// other option
|
||||
/*#define CAN_QUANTA 16
|
||||
#define CAN_SEQ1 13
|
||||
#define CAN_SEQ2 2*/
|
||||
|
||||
// this is needed for 1 mbps support
|
||||
#define CAN_QUANTA 8
|
||||
#define CAN_SEQ1 6 // roundf(quanta * 0.875f) - 1;
|
||||
#define CAN_SEQ2 1 // roundf(quanta * 0.125f);
|
||||
|
||||
#define CAN_PCLK 24000
|
||||
// 333 = 33.3 kbps
|
||||
// 5000 = 500 kbps
|
||||
#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10 / (x))
|
||||
|
||||
void can_autobaud_speed_increment(uint8_t can_number) {
|
||||
uint32_t autobaud_speed = can_autobaud_speeds[0];
|
||||
uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number);
|
||||
for (int i = 0; i < AUTOBAUD_SPEEDS_LEN; i++) {
|
||||
if (can_speed[bus_number] == can_autobaud_speeds[i]) {
|
||||
if (i+1 < AUTOBAUD_SPEEDS_LEN) {
|
||||
autobaud_speed = can_autobaud_speeds[i+1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
can_speed[bus_number] = autobaud_speed;
|
||||
#ifdef DEBUG
|
||||
CAN_TypeDef* CAN = CANIF_FROM_CAN_NUM(can_number);
|
||||
puts(CAN_NAME_FROM_CANIF(CAN));
|
||||
puts(" auto-baud test ");
|
||||
putui(can_speed[bus_number]);
|
||||
puts(" cbps\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void process_can(uint8_t can_number);
|
||||
|
||||
void can_set_speed(uint8_t can_number) {
|
||||
@@ -162,41 +124,14 @@ void can_set_speed(uint8_t can_number) {
|
||||
uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number);
|
||||
|
||||
while (true) {
|
||||
// initialization mode
|
||||
CAN->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ;
|
||||
while((CAN->MSR & CAN_MSR_INAK) != CAN_MSR_INAK);
|
||||
|
||||
// set time quanta from defines
|
||||
CAN->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) |
|
||||
(CAN_BTR_TS2_0 * (CAN_SEQ2-1)) |
|
||||
(can_speed_to_prescaler(can_speed[bus_number]) - 1);
|
||||
|
||||
// silent loopback mode for debugging
|
||||
if (can_loopback) {
|
||||
CAN->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM;
|
||||
}
|
||||
if (can_silent & (1 << can_number)) {
|
||||
CAN->BTR |= CAN_BTR_SILM;
|
||||
}
|
||||
|
||||
// reset
|
||||
CAN->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM;
|
||||
|
||||
#define CAN_TIMEOUT 1000000
|
||||
int tmp = 0;
|
||||
while((CAN->MSR & CAN_MSR_INAK) == CAN_MSR_INAK && tmp < CAN_TIMEOUT) tmp++;
|
||||
if (tmp < CAN_TIMEOUT) {
|
||||
if (llcan_set_speed(CAN, can_speed[bus_number], can_loopback, can_silent & (1 << can_number))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (can_autobaud_enabled[bus_number]) {
|
||||
can_autobaud_speed_increment(can_number);
|
||||
} else {
|
||||
puts("CAN init FAILED!!!!!\n");
|
||||
puth(can_number); puts(" ");
|
||||
puth(BUS_NUM_FROM_CAN_NUM(can_number)); puts("\n");
|
||||
return;
|
||||
}
|
||||
puts("CAN init FAILED!!!!!\n");
|
||||
puth(can_number); puts(" ");
|
||||
puth(BUS_NUM_FROM_CAN_NUM(can_number)); puts("\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,40 +142,7 @@ void can_init(uint8_t can_number) {
|
||||
set_can_enable(CAN, 1);
|
||||
can_set_speed(can_number);
|
||||
|
||||
// accept all filter
|
||||
CAN->FMR |= CAN_FMR_FINIT;
|
||||
|
||||
// no mask
|
||||
CAN->sFilterRegister[0].FR1 = 0;
|
||||
CAN->sFilterRegister[0].FR2 = 0;
|
||||
CAN->sFilterRegister[14].FR1 = 0;
|
||||
CAN->sFilterRegister[14].FR2 = 0;
|
||||
CAN->FA1R |= 1 | (1 << 14);
|
||||
|
||||
CAN->FMR &= ~(CAN_FMR_FINIT);
|
||||
|
||||
// enable certain CAN interrupts
|
||||
CAN->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE;
|
||||
|
||||
switch (can_number) {
|
||||
case 0:
|
||||
NVIC_EnableIRQ(CAN1_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN1_SCE_IRQn);
|
||||
break;
|
||||
case 1:
|
||||
NVIC_EnableIRQ(CAN2_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN2_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN2_SCE_IRQn);
|
||||
break;
|
||||
#ifdef CAN3
|
||||
case 2:
|
||||
NVIC_EnableIRQ(CAN3_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN3_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN3_SCE_IRQn);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
llcan_init(CAN);
|
||||
|
||||
// in case there are queued up messages
|
||||
process_can(can_number);
|
||||
@@ -253,7 +155,6 @@ void can_init_all() {
|
||||
}
|
||||
|
||||
void can_set_gmlan(int bus) {
|
||||
#ifdef PANDA
|
||||
if (bus == -1 || bus != can_num_lookup[3]) {
|
||||
// GMLAN OFF
|
||||
switch (can_num_lookup[3]) {
|
||||
@@ -284,7 +185,7 @@ void can_set_gmlan(int bus) {
|
||||
can_num_lookup[1] = -1;
|
||||
can_num_lookup[3] = 1;
|
||||
can_init(1);
|
||||
} else if (bus == 2 && revision == PANDA_REV_C) {
|
||||
} else if (bus == 2) {
|
||||
puts("GMLAN on CAN3\n");
|
||||
// GMLAN on CAN3
|
||||
set_can_mode(2, 1);
|
||||
@@ -293,7 +194,6 @@ void can_set_gmlan(int bus) {
|
||||
can_num_lookup[3] = 2;
|
||||
can_init(2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// CAN error
|
||||
@@ -319,34 +219,8 @@ void can_sce(CAN_TypeDef *CAN) {
|
||||
puts("\n");
|
||||
#endif
|
||||
|
||||
uint8_t can_number = CAN_NUM_FROM_CANIF(CAN);
|
||||
uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number);
|
||||
|
||||
if (CAN->MSR & CAN_MSR_WKUI) {
|
||||
//Waking from sleep
|
||||
#ifdef DEBUG
|
||||
puts("WAKE\n");
|
||||
#endif
|
||||
set_can_enable(CAN, 1);
|
||||
CAN->MSR &= ~(CAN_MSR_WKUI);
|
||||
CAN->MSR = CAN->MSR;
|
||||
#ifdef PANDA
|
||||
power_save_reset_timer();
|
||||
#endif
|
||||
} else {
|
||||
can_err_cnt += 1;
|
||||
|
||||
|
||||
if (can_autobaud_enabled[bus_number] && (CAN->ESR & CAN_ESR_LEC)) {
|
||||
can_autobaud_speed_increment(can_number);
|
||||
can_set_speed(can_number);
|
||||
}
|
||||
|
||||
// clear current send
|
||||
CAN->TSR |= CAN_TSR_ABRQ0;
|
||||
CAN->MSR &= ~(CAN_MSR_ERRI);
|
||||
CAN->MSR = CAN->MSR;
|
||||
}
|
||||
can_err_cnt += 1;
|
||||
llcan_clear_send(CAN);
|
||||
exit_critical_section();
|
||||
}
|
||||
|
||||
@@ -354,9 +228,6 @@ void can_sce(CAN_TypeDef *CAN) {
|
||||
|
||||
void process_can(uint8_t can_number) {
|
||||
if (can_number == 0xff) return;
|
||||
#ifdef PANDA
|
||||
power_save_reset_timer();
|
||||
#endif
|
||||
|
||||
enter_critical_section();
|
||||
|
||||
@@ -422,22 +293,9 @@ void process_can(uint8_t can_number) {
|
||||
// CAN receive handlers
|
||||
// blink blue when we are receiving CAN messages
|
||||
void can_rx(uint8_t can_number) {
|
||||
#ifdef PANDA
|
||||
power_save_reset_timer();
|
||||
#endif
|
||||
CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number);
|
||||
uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number);
|
||||
while (CAN->RF0R & CAN_RF0R_FMP0) {
|
||||
if (can_autobaud_enabled[bus_number]) {
|
||||
can_autobaud_enabled[bus_number] = false;
|
||||
puts(CAN_NAME_FROM_CANIF(CAN));
|
||||
#ifdef DEBUG
|
||||
puts(" auto-baud ");
|
||||
putui(can_speed[bus_number]);
|
||||
puts(" cbps\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
can_rx_cnt += 1;
|
||||
|
||||
// can is live
|
||||
@@ -454,25 +312,19 @@ void can_rx(uint8_t can_number) {
|
||||
to_push.RDTR = (to_push.RDTR & 0xFFFF000F) | (bus_number << 4);
|
||||
|
||||
// forwarding (panda only)
|
||||
#ifdef PANDA
|
||||
if ((get_lline_status() != 0) || !relay_control) { //Relay engaged or relay isn't controlled, allow fwd
|
||||
int bus_fwd_num = can_forwarding[bus_number] != -1 ? can_forwarding[bus_number] : safety_fwd_hook(bus_number, &to_push);
|
||||
if (bus_fwd_num != -1) {
|
||||
CAN_FIFOMailBox_TypeDef to_send;
|
||||
to_send.RIR = to_push.RIR | 1; // TXRQ
|
||||
to_send.RDTR = to_push.RDTR;
|
||||
to_send.RDLR = to_push.RDLR;
|
||||
to_send.RDHR = to_push.RDHR;
|
||||
can_send(&to_send, bus_fwd_num);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
int bus_fwd_num = can_forwarding[bus_number] != -1 ? can_forwarding[bus_number] : safety_fwd_hook(bus_number, &to_push);
|
||||
if (bus_fwd_num != -1) {
|
||||
CAN_FIFOMailBox_TypeDef to_send;
|
||||
to_send.RIR = to_push.RIR | 1; // TXRQ
|
||||
to_send.RDTR = to_push.RDTR;
|
||||
to_send.RDLR = to_push.RDLR;
|
||||
to_send.RDHR = to_push.RDHR;
|
||||
can_send(&to_send, bus_fwd_num);
|
||||
}
|
||||
|
||||
safety_rx_hook(&to_push);
|
||||
|
||||
#ifdef PANDA
|
||||
set_led(LED_BLUE, 1);
|
||||
#endif
|
||||
set_led(LED_BLUE, 1);
|
||||
can_push(&can_rx_q, &to_push);
|
||||
|
||||
// next
|
||||
@@ -480,8 +332,6 @@ void can_rx(uint8_t can_number) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CUSTOM_CAN_INTERRUPTS
|
||||
|
||||
void CAN1_TX_IRQHandler() { process_can(0); }
|
||||
void CAN1_RX0_IRQHandler() { can_rx(0); }
|
||||
void CAN1_SCE_IRQHandler() { can_sce(CAN1); }
|
||||
@@ -490,25 +340,19 @@ void CAN2_TX_IRQHandler() { process_can(1); }
|
||||
void CAN2_RX0_IRQHandler() { can_rx(1); }
|
||||
void CAN2_SCE_IRQHandler() { can_sce(CAN2); }
|
||||
|
||||
#ifdef CAN3
|
||||
void CAN3_TX_IRQHandler() { process_can(2); }
|
||||
void CAN3_RX0_IRQHandler() { can_rx(2); }
|
||||
void CAN3_SCE_IRQHandler() { can_sce(CAN3); }
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) {
|
||||
if (safety_tx_hook(to_push) && !can_autobaud_enabled[bus_number]) {
|
||||
if (safety_tx_hook(to_push)) {
|
||||
if (bus_number < BUS_MAX) {
|
||||
// add CAN packet to send queue
|
||||
// bus number isn't passed through
|
||||
to_push->RDTR &= 0xF;
|
||||
if (bus_number == 3 && can_num_lookup[3] == 0xFF) {
|
||||
#ifdef PANDA
|
||||
// TODO: why uint8 bro? only int8?
|
||||
bitbang_gmlan(to_push);
|
||||
#endif
|
||||
} else {
|
||||
can_push(can_queues[bus_number], to_push);
|
||||
process_can(CAN_NUM_FROM_BUS_NUM(bus_number));
|
||||
@@ -520,3 +364,4 @@ void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) {
|
||||
void can_set_forwarding(int from, int to) {
|
||||
can_forwarding[from] = to;
|
||||
}
|
||||
|
||||
|
||||
40
panda/board/drivers/clock.h
Normal file
40
panda/board/drivers/clock.h
Normal file
@@ -0,0 +1,40 @@
|
||||
void clock_init() {
|
||||
// enable external oscillator
|
||||
RCC->CR |= RCC_CR_HSEON;
|
||||
while ((RCC->CR & RCC_CR_HSERDY) == 0);
|
||||
|
||||
// divide shit
|
||||
RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4;
|
||||
|
||||
// 16mhz crystal
|
||||
RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 |
|
||||
RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE;
|
||||
|
||||
// start PLL
|
||||
RCC->CR |= RCC_CR_PLLON;
|
||||
while ((RCC->CR & RCC_CR_PLLRDY) == 0);
|
||||
|
||||
// Configure Flash prefetch, Instruction cache, Data cache and wait state
|
||||
// *** without this, it breaks ***
|
||||
FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
|
||||
|
||||
// switch to PLL
|
||||
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
|
||||
|
||||
// *** running on PLL ***
|
||||
}
|
||||
|
||||
void watchdog_init() {
|
||||
// setup watchdog
|
||||
IWDG->KR = 0x5555;
|
||||
IWDG->PR = 0; // divider /4
|
||||
// 0 = 0.125 ms, let's have a 50ms watchdog
|
||||
IWDG->RLR = 400 - 1;
|
||||
IWDG->KR = 0xCCCC;
|
||||
}
|
||||
|
||||
void watchdog_feed() {
|
||||
IWDG->KR = 0xAAAA;
|
||||
}
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
#ifndef PANDA_DRIVERS_H
|
||||
#define PANDA_DRIVERS_H
|
||||
|
||||
// ********************* LLGPIO *********************
|
||||
|
||||
#define MODE_INPUT 0
|
||||
#define MODE_OUTPUT 1
|
||||
#define MODE_ALTERNATE 2
|
||||
#define MODE_ANALOG 3
|
||||
|
||||
#define PULL_NONE 0
|
||||
#define PULL_UP 1
|
||||
#define PULL_DOWN 2
|
||||
|
||||
void set_gpio_mode(GPIO_TypeDef *GPIO, int pin, int mode);
|
||||
void set_gpio_output(GPIO_TypeDef *GPIO, int pin, int val);
|
||||
void set_gpio_alternate(GPIO_TypeDef *GPIO, int pin, int mode);
|
||||
void set_gpio_pullup(GPIO_TypeDef *GPIO, int pin, int mode);
|
||||
|
||||
int get_gpio_input(GPIO_TypeDef *GPIO, int pin);
|
||||
|
||||
|
||||
// ********************* USB *********************
|
||||
// IRQs: OTG_FS
|
||||
|
||||
typedef union {
|
||||
uint16_t w;
|
||||
struct BW {
|
||||
uint8_t msb;
|
||||
uint8_t lsb;
|
||||
}
|
||||
bw;
|
||||
}
|
||||
uint16_t_uint8_t;
|
||||
|
||||
typedef union _USB_Setup {
|
||||
uint32_t d8[2];
|
||||
struct _SetupPkt_Struc
|
||||
{
|
||||
uint8_t bmRequestType;
|
||||
uint8_t bRequest;
|
||||
uint16_t_uint8_t wValue;
|
||||
uint16_t_uint8_t wIndex;
|
||||
uint16_t_uint8_t wLength;
|
||||
} b;
|
||||
}
|
||||
USB_Setup_TypeDef;
|
||||
|
||||
void usb_init();
|
||||
int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired);
|
||||
int usb_cb_ep1_in(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_ep2_out(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_ep3_out(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_enumeration_complete();
|
||||
|
||||
|
||||
// ********************* UART *********************
|
||||
// IRQs: USART1, USART2, USART3, UART5
|
||||
|
||||
#define FIFO_SIZE 0x400
|
||||
typedef struct uart_ring {
|
||||
uint16_t w_ptr_tx;
|
||||
uint16_t r_ptr_tx;
|
||||
uint8_t elems_tx[FIFO_SIZE];
|
||||
uint16_t w_ptr_rx;
|
||||
uint16_t r_ptr_rx;
|
||||
uint8_t elems_rx[FIFO_SIZE];
|
||||
USART_TypeDef *uart;
|
||||
void (*callback)(struct uart_ring*);
|
||||
} uart_ring;
|
||||
|
||||
void uart_init(USART_TypeDef *u, int baud);
|
||||
|
||||
int getc(uart_ring *q, char *elem);
|
||||
int putc(uart_ring *q, char elem);
|
||||
|
||||
int puts(const char *a);
|
||||
void puth(unsigned int i);
|
||||
void hexdump(const void *a, int l);
|
||||
|
||||
|
||||
// ********************* ADC *********************
|
||||
|
||||
void adc_init();
|
||||
uint32_t adc_get(int channel);
|
||||
|
||||
|
||||
// ********************* DAC *********************
|
||||
|
||||
void dac_init();
|
||||
void dac_set(int channel, uint32_t value);
|
||||
|
||||
|
||||
// ********************* TIMER *********************
|
||||
|
||||
void timer_init(TIM_TypeDef *TIM, int psc);
|
||||
|
||||
|
||||
// ********************* SPI *********************
|
||||
// IRQs: DMA2_Stream2, DMA2_Stream3, EXTI4
|
||||
|
||||
void spi_init();
|
||||
int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out);
|
||||
|
||||
|
||||
// ********************* CAN *********************
|
||||
// IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE
|
||||
// CAN2_TX, CAN2_RX0, CAN2_SCE
|
||||
// CAN3_TX, CAN3_RX0, CAN3_SCE
|
||||
|
||||
typedef struct {
|
||||
uint32_t w_ptr;
|
||||
uint32_t r_ptr;
|
||||
uint32_t fifo_size;
|
||||
CAN_FIFOMailBox_TypeDef *elems;
|
||||
} can_ring;
|
||||
|
||||
#define CAN_BUS_RET_FLAG 0x80
|
||||
#define CAN_BUS_NUM_MASK 0x7F
|
||||
|
||||
#ifdef PANDA
|
||||
#define BUS_MAX 4
|
||||
#else
|
||||
#define BUS_MAX 2
|
||||
#endif
|
||||
|
||||
extern int can_live, pending_can_live;
|
||||
|
||||
// must reinit after changing these
|
||||
extern int can_loopback, can_silent;
|
||||
extern uint32_t can_speed[];
|
||||
|
||||
void can_set_forwarding(int from, int to);
|
||||
|
||||
void can_init(uint8_t can_number);
|
||||
void can_init_all();
|
||||
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number);
|
||||
int can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -114,8 +114,6 @@ int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) {
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifdef PANDA
|
||||
|
||||
void setup_timer4() {
|
||||
// setup
|
||||
TIM4->PSC = 48-1; // tick on 1 us
|
||||
@@ -273,4 +271,3 @@ void bitbang_gmlan(CAN_FIFOMailBox_TypeDef *to_bang) {
|
||||
setup_timer4();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
80
panda/board/drivers/llcan.h
Normal file
80
panda/board/drivers/llcan.h
Normal file
@@ -0,0 +1,80 @@
|
||||
// this is needed for 1 mbps support
|
||||
#define CAN_QUANTA 8
|
||||
#define CAN_SEQ1 6 // roundf(quanta * 0.875f) - 1;
|
||||
#define CAN_SEQ2 1 // roundf(quanta * 0.125f);
|
||||
|
||||
#define CAN_PCLK 24000
|
||||
// 333 = 33.3 kbps
|
||||
// 5000 = 500 kbps
|
||||
#define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10 / (x))
|
||||
|
||||
bool llcan_set_speed(CAN_TypeDef *CAN, uint32_t speed, bool loopback, bool silent) {
|
||||
// initialization mode
|
||||
CAN->MCR = CAN_MCR_TTCM | CAN_MCR_INRQ;
|
||||
while((CAN->MSR & CAN_MSR_INAK) != CAN_MSR_INAK);
|
||||
|
||||
// set time quanta from defines
|
||||
CAN->BTR = (CAN_BTR_TS1_0 * (CAN_SEQ1-1)) |
|
||||
(CAN_BTR_TS2_0 * (CAN_SEQ2-1)) |
|
||||
(can_speed_to_prescaler(speed) - 1);
|
||||
|
||||
// silent loopback mode for debugging
|
||||
if (loopback) {
|
||||
CAN->BTR |= CAN_BTR_SILM | CAN_BTR_LBKM;
|
||||
}
|
||||
if (silent) {
|
||||
CAN->BTR |= CAN_BTR_SILM;
|
||||
}
|
||||
|
||||
// reset
|
||||
CAN->MCR = CAN_MCR_TTCM | CAN_MCR_ABOM;
|
||||
|
||||
#define CAN_TIMEOUT 1000000
|
||||
int tmp = 0;
|
||||
while((CAN->MSR & CAN_MSR_INAK) == CAN_MSR_INAK && tmp < CAN_TIMEOUT) tmp++;
|
||||
if (tmp < CAN_TIMEOUT) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void llcan_init(CAN_TypeDef *CAN) {
|
||||
// accept all filter
|
||||
CAN->FMR |= CAN_FMR_FINIT;
|
||||
|
||||
// no mask
|
||||
CAN->sFilterRegister[0].FR1 = 0;
|
||||
CAN->sFilterRegister[0].FR2 = 0;
|
||||
CAN->sFilterRegister[14].FR1 = 0;
|
||||
CAN->sFilterRegister[14].FR2 = 0;
|
||||
CAN->FA1R |= 1 | (1 << 14);
|
||||
|
||||
CAN->FMR &= ~(CAN_FMR_FINIT);
|
||||
|
||||
// enable certain CAN interrupts
|
||||
CAN->IER |= CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE;
|
||||
|
||||
if (CAN == CAN1) {
|
||||
NVIC_EnableIRQ(CAN1_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN1_SCE_IRQn);
|
||||
} else if (CAN == CAN2) {
|
||||
NVIC_EnableIRQ(CAN2_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN2_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN2_SCE_IRQn);
|
||||
#ifdef CAN3
|
||||
} else if (CAN == CAN3) {
|
||||
NVIC_EnableIRQ(CAN3_TX_IRQn);
|
||||
NVIC_EnableIRQ(CAN3_RX0_IRQn);
|
||||
NVIC_EnableIRQ(CAN3_SCE_IRQn);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void llcan_clear_send(CAN_TypeDef *CAN) {
|
||||
CAN->TSR |= CAN_TSR_ABRQ0;
|
||||
CAN->MSR &= ~(CAN_MSR_ERRI);
|
||||
CAN->MSR = CAN->MSR;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#define MODE_INPUT 0
|
||||
#define MODE_OUTPUT 1
|
||||
#define MODE_ALTERNATE 2
|
||||
#define MODE_ANALOG 3
|
||||
|
||||
#define PULL_NONE 0
|
||||
#define PULL_UP 1
|
||||
#define PULL_DOWN 2
|
||||
|
||||
void set_gpio_mode(GPIO_TypeDef *GPIO, int pin, int mode) {
|
||||
uint32_t tmp = GPIO->MODER;
|
||||
tmp &= ~(3 << (pin*2));
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#ifdef PANDA
|
||||
|
||||
int relay_control = 0; // True if relay is controlled through l-line
|
||||
|
||||
/* Conrol a relay connected to l-line pin */
|
||||
|
||||
// 160us cycles, 1 high, 25 low
|
||||
|
||||
volatile int turn_on_relay = 0;
|
||||
volatile int on_cycles = 25;
|
||||
|
||||
//5s timeout
|
||||
#define LLINE_TIMEOUT_CYCLES 31250
|
||||
volatile int timeout_cycles = LLINE_TIMEOUT_CYCLES;
|
||||
|
||||
void TIM5_IRQHandler(void) {
|
||||
if (TIM5->SR & TIM_SR_UIF) {
|
||||
on_cycles--;
|
||||
timeout_cycles--;
|
||||
if (timeout_cycles == 0) {
|
||||
turn_on_relay = 0;
|
||||
}
|
||||
if (on_cycles > 0) {
|
||||
if (turn_on_relay) {
|
||||
set_gpio_output(GPIOC, 10, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
set_gpio_output(GPIOC, 10, 1);
|
||||
on_cycles = 25;
|
||||
}
|
||||
}
|
||||
TIM5->ARR = 160-1;
|
||||
TIM5->SR = 0;
|
||||
}
|
||||
|
||||
void lline_relay_init (void) {
|
||||
set_lline_output(0);
|
||||
relay_control = 1;
|
||||
set_gpio_output(GPIOC, 10, 1);
|
||||
|
||||
// setup
|
||||
TIM5->PSC = 48-1; // tick on 1 us
|
||||
TIM5->CR1 = TIM_CR1_CEN; // enable
|
||||
TIM5->ARR = 50-1; // 50 us
|
||||
TIM5->DIER = TIM_DIER_UIE; // update interrupt
|
||||
TIM5->CNT = 0;
|
||||
|
||||
NVIC_EnableIRQ(TIM5_IRQn);
|
||||
|
||||
#ifdef DEBUG
|
||||
puts("INIT LLINE\n");
|
||||
puts(" SR ");
|
||||
putui(TIM5->SR);
|
||||
puts(" PSC ");
|
||||
putui(TIM5->PSC);
|
||||
puts(" CR1 ");
|
||||
putui(TIM5->CR1);
|
||||
puts(" ARR ");
|
||||
putui(TIM5->ARR);
|
||||
puts(" DIER ");
|
||||
putui(TIM5->DIER);
|
||||
puts(" SR ");
|
||||
putui(TIM5->SR);
|
||||
puts(" CNT ");
|
||||
putui(TIM5->CNT);
|
||||
puts("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void lline_relay_release (void) {
|
||||
set_lline_output(0);
|
||||
relay_control = 0;
|
||||
puts("RELEASE LLINE\n");
|
||||
set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3);
|
||||
NVIC_DisableIRQ(TIM5_IRQn);
|
||||
}
|
||||
|
||||
void set_lline_output(int to_set) {
|
||||
timeout_cycles = LLINE_TIMEOUT_CYCLES;
|
||||
turn_on_relay = to_set;
|
||||
}
|
||||
|
||||
int get_lline_status() {
|
||||
return turn_on_relay;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,10 @@
|
||||
// IRQs: DMA2_Stream2, DMA2_Stream3, EXTI4
|
||||
|
||||
void spi_init();
|
||||
int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out);
|
||||
|
||||
// end API
|
||||
|
||||
#define SPI_BUF_SIZE 256
|
||||
uint8_t spi_buf[SPI_BUF_SIZE];
|
||||
int spi_buf_count = 0;
|
||||
@@ -23,8 +28,8 @@ void spi_init() {
|
||||
|
||||
// setup interrupt on falling edge of SPI enable (on PA4)
|
||||
SYSCFG->EXTICR[2] = SYSCFG_EXTICR2_EXTI4_PA;
|
||||
EXTI->IMR = (1 << 4);
|
||||
EXTI->FTSR = (1 << 4);
|
||||
EXTI->IMR |= (1 << 4);
|
||||
EXTI->FTSR |= (1 << 4);
|
||||
NVIC_EnableIRQ(EXTI4_IRQn);
|
||||
}
|
||||
|
||||
@@ -108,7 +113,7 @@ void DMA2_Stream3_IRQHandler(void) {
|
||||
}
|
||||
|
||||
void EXTI4_IRQHandler(void) {
|
||||
volatile int pr = EXTI->PR;
|
||||
volatile int pr = EXTI->PR & (1 << 4);
|
||||
#ifdef DEBUG_SPI
|
||||
puts("exti4\n");
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
// IRQs: USART1, USART2, USART3, UART5
|
||||
|
||||
#define FIFO_SIZE 0x400
|
||||
typedef struct uart_ring {
|
||||
uint16_t w_ptr_tx;
|
||||
uint16_t r_ptr_tx;
|
||||
uint8_t elems_tx[FIFO_SIZE];
|
||||
uint16_t w_ptr_rx;
|
||||
uint16_t r_ptr_rx;
|
||||
uint8_t elems_rx[FIFO_SIZE];
|
||||
USART_TypeDef *uart;
|
||||
void (*callback)(struct uart_ring*);
|
||||
} uart_ring;
|
||||
|
||||
void uart_init(USART_TypeDef *u, int baud);
|
||||
|
||||
int getc(uart_ring *q, char *elem);
|
||||
int putc(uart_ring *q, char elem);
|
||||
|
||||
int puts(const char *a);
|
||||
void puth(unsigned int i);
|
||||
void hexdump(const void *a, int l);
|
||||
|
||||
|
||||
// ***************************** serial port queues *****************************
|
||||
|
||||
// esp = USART1
|
||||
|
||||
@@ -1,5 +1,35 @@
|
||||
// IRQs: OTG_FS
|
||||
|
||||
typedef union {
|
||||
uint16_t w;
|
||||
struct BW {
|
||||
uint8_t msb;
|
||||
uint8_t lsb;
|
||||
}
|
||||
bw;
|
||||
}
|
||||
uint16_t_uint8_t;
|
||||
|
||||
typedef union _USB_Setup {
|
||||
uint32_t d8[2];
|
||||
struct _SetupPkt_Struc
|
||||
{
|
||||
uint8_t bmRequestType;
|
||||
uint8_t bRequest;
|
||||
uint16_t_uint8_t wValue;
|
||||
uint16_t_uint8_t wIndex;
|
||||
uint16_t_uint8_t wLength;
|
||||
} b;
|
||||
}
|
||||
USB_Setup_TypeDef;
|
||||
|
||||
void usb_init();
|
||||
int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired);
|
||||
int usb_cb_ep1_in(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_ep2_out(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_ep3_out(uint8_t *usbdata, int len, int hardwired);
|
||||
void usb_cb_enumeration_complete();
|
||||
|
||||
// **** supporting defines ****
|
||||
|
||||
typedef struct
|
||||
@@ -186,17 +216,10 @@ uint16_t string_manufacturer_desc[] = {
|
||||
'c', 'o', 'm', 'm', 'a', '.', 'a', 'i'
|
||||
};
|
||||
|
||||
#ifdef PANDA
|
||||
uint16_t string_product_desc[] = {
|
||||
STRING_DESCRIPTOR_HEADER(5),
|
||||
'p', 'a', 'n', 'd', 'a'
|
||||
};
|
||||
#else
|
||||
uint16_t string_product_desc[] = {
|
||||
STRING_DESCRIPTOR_HEADER(5),
|
||||
'N', 'E', 'O', 'v', '1'
|
||||
};
|
||||
#endif
|
||||
|
||||
// default serial number when we're not a panda
|
||||
uint16_t string_serial_desc[] = {
|
||||
@@ -210,7 +233,6 @@ uint16_t string_configuration_desc[] = {
|
||||
'0', '1' // "01"
|
||||
};
|
||||
|
||||
#ifdef PANDA
|
||||
// WCID (auto install WinUSB driver)
|
||||
// https://github.com/pbatard/libwdi/wiki/WCID-Devices
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation#automatic-installation-of--winusb-without-an-inf-file
|
||||
@@ -360,8 +382,6 @@ uint8_t winusb_20_desc[WINUSB_PLATFORM_DESCRIPTOR_LENGTH] = {
|
||||
'1', 0x00, 'a', 0x00, 'd', 0x00, 'e', 0x00, '9', 0x00, '}', 0x00, 0x00, 0x00 // 78 bytes
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// current packet
|
||||
USB_Setup_TypeDef setup;
|
||||
uint8_t usbdata[0x100];
|
||||
@@ -550,7 +570,7 @@ void usb_setup() {
|
||||
USB_WritePacket((uint8_t*)string_product_desc, min(sizeof(string_product_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
case STRING_OFFSET_ISERIAL:
|
||||
#ifdef PANDA
|
||||
#ifdef UID_BASE
|
||||
resp[0] = 0x02 + 12*4;
|
||||
resp[1] = 0x03;
|
||||
|
||||
@@ -568,14 +588,12 @@ void usb_setup() {
|
||||
USB_WritePacket((const uint8_t *)string_serial_desc, min(sizeof(string_serial_desc), setup.b.wLength.w), 0);
|
||||
#endif
|
||||
break;
|
||||
#ifdef PANDA
|
||||
case STRING_OFFSET_ICONFIGURATION:
|
||||
USB_WritePacket((uint8_t*)string_configuration_desc, min(sizeof(string_configuration_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
case 238:
|
||||
USB_WritePacket((uint8_t*)string_238_desc, min(sizeof(string_238_desc), setup.b.wLength.w), 0);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
// nothing
|
||||
USB_WritePacket(0, 0, 0);
|
||||
@@ -583,12 +601,10 @@ void usb_setup() {
|
||||
}
|
||||
USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK;
|
||||
break;
|
||||
#ifdef PANDA
|
||||
case USB_DESC_TYPE_BINARY_OBJECT_STORE:
|
||||
USB_WritePacket(binary_object_store_desc, min(sizeof(binary_object_store_desc), setup.b.wLength.w), 0);
|
||||
USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
// nothing here?
|
||||
USB_WritePacket(0, 0, 0);
|
||||
@@ -609,7 +625,6 @@ void usb_setup() {
|
||||
USB_WritePacket(0, 0, 0);
|
||||
USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK;
|
||||
break;
|
||||
#ifdef PANDA
|
||||
case WEBUSB_VENDOR_CODE:
|
||||
switch (setup.b.wIndex.w) {
|
||||
case WEBUSB_REQ_GET_URL:
|
||||
@@ -641,7 +656,6 @@ void usb_setup() {
|
||||
USB_WritePacket_EP0(0, 0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
resp_len = usb_cb_control_msg(&setup, resp, 1);
|
||||
USB_WritePacket(resp, min(resp_len, setup.b.wLength.w), 0);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// this is last place with ifdef PANDA
|
||||
|
||||
#ifdef STM32F4
|
||||
#include "stm32f4xx_hal_gpio_ex.h"
|
||||
#else
|
||||
@@ -61,43 +63,6 @@ void detect() {
|
||||
|
||||
// ********************* bringup *********************
|
||||
|
||||
void clock_init() {
|
||||
// enable external oscillator
|
||||
RCC->CR |= RCC_CR_HSEON;
|
||||
while ((RCC->CR & RCC_CR_HSERDY) == 0);
|
||||
|
||||
// divide shit
|
||||
RCC->CFGR = RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4;
|
||||
#ifdef PANDA
|
||||
RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 |
|
||||
RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE;
|
||||
#else
|
||||
#ifdef PEDAL
|
||||
// comma pedal has a 16mhz crystal
|
||||
RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 |
|
||||
RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE;
|
||||
#else
|
||||
// NEO board has a 8mhz crystal
|
||||
RCC->PLLCFGR = RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 |
|
||||
RCC_PLLCFGR_PLLN_7 | RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLSRC_HSE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// start PLL
|
||||
RCC->CR |= RCC_CR_PLLON;
|
||||
while ((RCC->CR & RCC_CR_PLLRDY) == 0);
|
||||
|
||||
// Configure Flash prefetch, Instruction cache, Data cache and wait state
|
||||
// *** without this, it breaks ***
|
||||
FLASH->ACR = FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
|
||||
|
||||
// switch to PLL
|
||||
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
|
||||
|
||||
// *** running on PLL ***
|
||||
}
|
||||
|
||||
void periph_init() {
|
||||
// enable GPIOB, UART2, CAN, USB clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
|
||||
@@ -117,18 +82,16 @@ void periph_init() {
|
||||
RCC->APB1ENR |= RCC_APB1ENR_CAN3EN;
|
||||
#endif
|
||||
RCC->APB1ENR |= RCC_APB1ENR_DACEN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; // main counter
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // slow loop and pedal
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // gmlan_alt
|
||||
//RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;
|
||||
//RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
|
||||
//RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_SPI1EN;
|
||||
|
||||
// needed?
|
||||
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
|
||||
}
|
||||
|
||||
@@ -197,7 +160,7 @@ void set_can_mode(int can, int use_gmlan) {
|
||||
set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2);
|
||||
set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2);
|
||||
#ifdef CAN3
|
||||
} else if (revision == PANDA_REV_C && can == 2) {
|
||||
} else if (can == 2) {
|
||||
// A8,A15: disable normal mode
|
||||
set_gpio_mode(GPIOA, 8, MODE_INPUT);
|
||||
set_gpio_mode(GPIOA, 15, MODE_INPUT);
|
||||
@@ -218,11 +181,9 @@ void set_can_mode(int can, int use_gmlan) {
|
||||
set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2);
|
||||
#ifdef CAN3
|
||||
} else if (can == 2) {
|
||||
if(revision == PANDA_REV_C){
|
||||
// B3,B4: disable gmlan mode
|
||||
set_gpio_mode(GPIOB, 3, MODE_INPUT);
|
||||
set_gpio_mode(GPIOB, 4, MODE_INPUT);
|
||||
}
|
||||
// B3,B4: disable gmlan mode
|
||||
set_gpio_mode(GPIOB, 3, MODE_INPUT);
|
||||
set_gpio_mode(GPIOB, 4, MODE_INPUT);
|
||||
// A8,A15: normal mode
|
||||
set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3);
|
||||
set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3);
|
||||
@@ -377,11 +338,7 @@ void gpio_init() {
|
||||
|
||||
#ifdef PANDA
|
||||
// K-line enable moved from B4->B7 to make room for GMLAN on CAN3
|
||||
if (revision == PANDA_REV_C) {
|
||||
set_gpio_output(GPIOB, 7, 1); // REV C
|
||||
} else {
|
||||
set_gpio_output(GPIOB, 4, 1); // REV AB
|
||||
}
|
||||
set_gpio_output(GPIOB, 7, 1); // REV C
|
||||
|
||||
// C12,D2: K-Line setup on UART 5
|
||||
set_gpio_alternate(GPIOC, 12, GPIO_AF8_UART5);
|
||||
@@ -392,16 +349,12 @@ void gpio_init() {
|
||||
set_gpio_output(GPIOA, 14, 1);
|
||||
|
||||
// C10,C11: L-Line setup on USART 3
|
||||
// LLine now used for relay output
|
||||
set_gpio_output(GPIOC, 10, 1);
|
||||
//set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3);
|
||||
set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3);
|
||||
set_gpio_alternate(GPIOC, 11, GPIO_AF7_USART3);
|
||||
set_gpio_pullup(GPIOC, 11, PULL_UP);
|
||||
#endif
|
||||
|
||||
if (revision == PANDA_REV_C) {
|
||||
set_usb_power_mode(USB_POWER_CLIENT);
|
||||
}
|
||||
set_usb_power_mode(USB_POWER_CLIENT);
|
||||
}
|
||||
|
||||
// ********************* early bringup *********************
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
//#define EON
|
||||
|
||||
#include "config.h"
|
||||
#include "obj/gitversion.h"
|
||||
|
||||
// ********************* includes *********************
|
||||
|
||||
|
||||
#include "libc.h"
|
||||
#include "safety.h"
|
||||
#include "provision.h"
|
||||
|
||||
#include "drivers/drivers.h"
|
||||
|
||||
#include "drivers/llcan.h"
|
||||
#include "drivers/llgpio.h"
|
||||
#include "gpio.h"
|
||||
|
||||
@@ -16,25 +17,13 @@
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/usb.h"
|
||||
#include "drivers/gmlan_alt.h"
|
||||
#include "drivers/can.h"
|
||||
#include "drivers/spi.h"
|
||||
#include "drivers/timer.h"
|
||||
#include "drivers/clock.h"
|
||||
|
||||
#include "power_saving.h"
|
||||
|
||||
|
||||
// ***************************** fan *****************************
|
||||
|
||||
void fan_init() {
|
||||
// timer for fan PWM
|
||||
TIM3->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1;
|
||||
TIM3->CCER = TIM_CCER_CC3E;
|
||||
timer_init(TIM3, 10);
|
||||
}
|
||||
|
||||
void fan_set_speed(int fan_speed) {
|
||||
TIM3->CCR3 = fan_speed;
|
||||
}
|
||||
#include "safety.h"
|
||||
#include "drivers/can.h"
|
||||
|
||||
// ********************* serial debugging *********************
|
||||
|
||||
@@ -70,6 +59,41 @@ void debug_ring_callback(uart_ring *ring) {
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************** started logic *****************************
|
||||
|
||||
int is_gpio_started() {
|
||||
// ignition is on PA1
|
||||
return (GPIOA->IDR & (1 << 1)) == 0;
|
||||
}
|
||||
|
||||
void EXTI1_IRQHandler() {
|
||||
volatile int pr = EXTI->PR & (1 << 1);
|
||||
if (pr & (1 << 1)) {
|
||||
#ifdef DEBUG
|
||||
puts("got started interrupt\n");
|
||||
#endif
|
||||
|
||||
// jenky debounce
|
||||
delay(100000);
|
||||
|
||||
// set power savings mode here
|
||||
if (is_gpio_started() == 1) {
|
||||
power_save_disable();
|
||||
} else {
|
||||
power_save_enable();
|
||||
}
|
||||
EXTI->PR = (1 << 1);
|
||||
}
|
||||
}
|
||||
|
||||
void started_interrupt_init() {
|
||||
SYSCFG->EXTICR[1] = SYSCFG_EXTICR1_EXTI1_PA;
|
||||
EXTI->IMR |= (1 << 1);
|
||||
EXTI->RTSR |= (1 << 1);
|
||||
EXTI->FTSR |= (1 << 1);
|
||||
NVIC_EnableIRQ(EXTI1_IRQn);
|
||||
}
|
||||
|
||||
// ***************************** USB port *****************************
|
||||
|
||||
int get_health_pkt(void *dat) {
|
||||
@@ -85,40 +109,25 @@ int get_health_pkt(void *dat) {
|
||||
|
||||
//Voltage will be measured in mv. 5000 = 5V
|
||||
uint32_t voltage = adc_get(ADCCHAN_VOLTAGE);
|
||||
if (revision == PANDA_REV_AB) {
|
||||
//REVB has a 100, 27 (27/127) voltage divider
|
||||
//Here is the calculation for the scale
|
||||
//ADCV = VIN_S * (27/127) * (4095/3.3)
|
||||
//RETVAL = ADCV * s = VIN_S*1000
|
||||
//s = 1000/((4095/3.3)*(27/127)) = 3.79053046
|
||||
|
||||
//Avoid needing floating point math
|
||||
health->voltage = (voltage * 3791) / 1000;
|
||||
} else {
|
||||
//REVC has a 10, 1 (1/11) voltage divider
|
||||
//Here is the calculation for the scale (s)
|
||||
//ADCV = VIN_S * (1/11) * (4095/3.3)
|
||||
//RETVAL = ADCV * s = VIN_S*1000
|
||||
//s = 1000/((4095/3.3)*(1/11)) = 8.8623046875
|
||||
// REVC has a 10, 1 (1/11) voltage divider
|
||||
// Here is the calculation for the scale (s)
|
||||
// ADCV = VIN_S * (1/11) * (4095/3.3)
|
||||
// RETVAL = ADCV * s = VIN_S*1000
|
||||
// s = 1000/((4095/3.3)*(1/11)) = 8.8623046875
|
||||
|
||||
//Avoid needing floating point math
|
||||
health->voltage = (voltage * 8862) / 1000;
|
||||
}
|
||||
// Avoid needing floating point math
|
||||
health->voltage = (voltage * 8862) / 1000;
|
||||
|
||||
#ifdef PANDA
|
||||
health->current = adc_get(ADCCHAN_CURRENT);
|
||||
int safety_ignition = safety_ignition_hook();
|
||||
if (safety_ignition < 0) {
|
||||
//Use the GPIO pin to determine ignition
|
||||
health->started = (GPIOA->IDR & (1 << 1)) == 0;
|
||||
health->started = is_gpio_started();
|
||||
} else {
|
||||
//Current safety hooks want to determine ignition (ex: GM)
|
||||
health->started = safety_ignition;
|
||||
}
|
||||
#else
|
||||
health->current = 0;
|
||||
health->started = (GPIOC->IDR & (1 << 13)) != 0;
|
||||
#endif
|
||||
|
||||
health->controls_allowed = controls_allowed;
|
||||
health->gas_interceptor_detected = gas_interceptor_detected;
|
||||
@@ -143,7 +152,6 @@ void usb_cb_ep2_out(uint8_t *usbdata, int len, int hardwired) {
|
||||
uart_ring *ur = get_ring_by_number(usbdata[0]);
|
||||
if (!ur) return;
|
||||
if ((usbdata[0] < 2) || safety_tx_lin_hook(usbdata[0]-2, usbdata+1, len-1)) {
|
||||
if (ur == &esp_ring) power_save_reset_timer();
|
||||
for (int i = 1; i < len; i++) while (!putc(ur, usbdata[i]));
|
||||
}
|
||||
}
|
||||
@@ -163,14 +171,6 @@ void usb_cb_ep3_out(uint8_t *usbdata, int len, int hardwired) {
|
||||
|
||||
uint8_t bus_number = (to_push.RDTR >> 4) & CAN_BUS_NUM_MASK;
|
||||
can_send(&to_push, bus_number);
|
||||
|
||||
#ifdef PANDA
|
||||
// Enable relay on can message if allowed.
|
||||
// Temporary until OP has support for relay
|
||||
if (safety_relay_hook()) {
|
||||
set_lline_output(1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,16 +201,14 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
break;
|
||||
// **** 0xd0: fetch serial number
|
||||
case 0xd0:
|
||||
#ifdef PANDA
|
||||
// addresses are OTP
|
||||
if (setup->b.wValue.w == 1) {
|
||||
memcpy(resp, (void *)0x1fff79c0, 0x10);
|
||||
resp_len = 0x10;
|
||||
} else {
|
||||
get_provision_chunk(resp);
|
||||
resp_len = PROVISION_CHUNK_LEN;
|
||||
}
|
||||
#endif
|
||||
// addresses are OTP
|
||||
if (setup->b.wValue.w == 1) {
|
||||
memcpy(resp, (void *)0x1fff79c0, 0x10);
|
||||
resp_len = 0x10;
|
||||
} else {
|
||||
get_provision_chunk(resp);
|
||||
resp_len = PROVISION_CHUNK_LEN;
|
||||
}
|
||||
break;
|
||||
// **** 0xd1: enter bootloader mode
|
||||
case 0xd1:
|
||||
@@ -235,10 +233,6 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
case 0xd2:
|
||||
resp_len = get_health_pkt(resp);
|
||||
break;
|
||||
// **** 0xd3: set fan speed
|
||||
case 0xd3:
|
||||
fan_set_speed(setup->b.wValue.w);
|
||||
break;
|
||||
// **** 0xd6: get version
|
||||
case 0xd6:
|
||||
COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN)
|
||||
@@ -273,44 +267,43 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
break;
|
||||
// **** 0xdb: set GMLAN multiplexing mode
|
||||
case 0xdb:
|
||||
#ifdef PANDA
|
||||
if (setup->b.wValue.w == 1) {
|
||||
// GMLAN ON
|
||||
if (setup->b.wIndex.w == 1) {
|
||||
can_set_gmlan(1);
|
||||
} else if (setup->b.wIndex.w == 2) {
|
||||
// might be ignored on rev b panda
|
||||
can_set_gmlan(2);
|
||||
}
|
||||
} else {
|
||||
can_set_gmlan(-1);
|
||||
if (setup->b.wValue.w == 1) {
|
||||
// GMLAN ON
|
||||
if (setup->b.wIndex.w == 1) {
|
||||
can_set_gmlan(1);
|
||||
} else if (setup->b.wIndex.w == 2) {
|
||||
can_set_gmlan(2);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
can_set_gmlan(-1);
|
||||
}
|
||||
break;
|
||||
// **** 0xdc: set safety mode
|
||||
case 0xdc:
|
||||
// this is the only way to leave silent mode
|
||||
// and it's blocked over WiFi
|
||||
// Allow ELM security mode to be set over wifi.
|
||||
if (hardwired || setup->b.wValue.w == SAFETY_NOOUTPUT || setup->b.wValue.w == SAFETY_ELM327) {
|
||||
if (hardwired || (setup->b.wValue.w == SAFETY_NOOUTPUT) || (setup->b.wValue.w == SAFETY_ELM327)) {
|
||||
safety_set_mode(setup->b.wValue.w, (int16_t)setup->b.wIndex.w);
|
||||
switch (setup->b.wValue.w) {
|
||||
case SAFETY_NOOUTPUT:
|
||||
can_silent = ALL_CAN_SILENT;
|
||||
break;
|
||||
case SAFETY_ELM327:
|
||||
can_silent = ALL_CAN_BUT_MAIN_SILENT;
|
||||
can_autobaud_enabled[0] = false;
|
||||
break;
|
||||
default:
|
||||
can_silent = ALL_CAN_LIVE;
|
||||
can_autobaud_enabled[0] = false;
|
||||
can_autobaud_enabled[1] = false;
|
||||
#ifdef PANDA
|
||||
can_autobaud_enabled[2] = false;
|
||||
#endif
|
||||
break;
|
||||
if (safety_ignition_hook() != -1) {
|
||||
// if the ignition hook depends on something other than the started GPIO
|
||||
// we have to disable power savings (fix for GM and Tesla)
|
||||
power_save_disable();
|
||||
}
|
||||
#ifndef EON
|
||||
// always LIVE on EON
|
||||
switch (setup->b.wValue.w) {
|
||||
case SAFETY_NOOUTPUT:
|
||||
can_silent = ALL_CAN_SILENT;
|
||||
break;
|
||||
case SAFETY_ELM327:
|
||||
can_silent = ALL_CAN_BUT_MAIN_SILENT;
|
||||
break;
|
||||
default:
|
||||
can_silent = ALL_CAN_LIVE;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
can_init_all();
|
||||
}
|
||||
break;
|
||||
@@ -318,21 +311,26 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
case 0xdd:
|
||||
// wValue = Can Bus Num to forward from
|
||||
// wIndex = Can Bus Num to forward to
|
||||
if (setup->b.wValue.w < BUS_MAX && setup->b.wIndex.w < BUS_MAX &&
|
||||
setup->b.wValue.w != setup->b.wIndex.w) { // set forwarding
|
||||
if ((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w < BUS_MAX) &&
|
||||
(setup->b.wValue.w != setup->b.wIndex.w)) { // set forwarding
|
||||
can_set_forwarding(setup->b.wValue.w, setup->b.wIndex.w & CAN_BUS_NUM_MASK);
|
||||
} else if(setup->b.wValue.w < BUS_MAX && setup->b.wIndex.w == 0xFF){ //Clear Forwarding
|
||||
} else if((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w == 0xFF)){ //Clear Forwarding
|
||||
can_set_forwarding(setup->b.wValue.w, -1);
|
||||
}
|
||||
break;
|
||||
// **** 0xde: set can bitrate
|
||||
case 0xde:
|
||||
if (setup->b.wValue.w < BUS_MAX) {
|
||||
can_autobaud_enabled[setup->b.wValue.w] = false;
|
||||
can_speed[setup->b.wValue.w] = setup->b.wIndex.w;
|
||||
can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w));
|
||||
}
|
||||
break;
|
||||
// **** 0xdf: set long controls allowed
|
||||
case 0xdf:
|
||||
if (hardwired) {
|
||||
long_controls_allowed = setup->b.wValue.w & 1;
|
||||
}
|
||||
break;
|
||||
// **** 0xe0: uart read
|
||||
case 0xe0:
|
||||
ur = get_ring_by_number(setup->b.wValue.w);
|
||||
@@ -386,17 +384,15 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
break;
|
||||
// **** 0xe6: set USB power
|
||||
case 0xe6:
|
||||
if (revision == PANDA_REV_C) {
|
||||
if (setup->b.wValue.w == 1) {
|
||||
puts("user setting CDP mode\n");
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
} else if (setup->b.wValue.w == 2) {
|
||||
puts("user setting DCP mode\n");
|
||||
set_usb_power_mode(USB_POWER_DCP);
|
||||
} else {
|
||||
puts("user setting CLIENT mode\n");
|
||||
set_usb_power_mode(USB_POWER_CLIENT);
|
||||
}
|
||||
if (setup->b.wValue.w == 1) {
|
||||
puts("user setting CDP mode\n");
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
} else if (setup->b.wValue.w == 2) {
|
||||
puts("user setting DCP mode\n");
|
||||
set_usb_power_mode(USB_POWER_DCP);
|
||||
} else {
|
||||
puts("user setting CLIENT mode\n");
|
||||
set_usb_power_mode(USB_POWER_CLIENT);
|
||||
}
|
||||
break;
|
||||
// **** 0xf0: do k-line wValue pulse on uart2 for Acura
|
||||
@@ -452,16 +448,6 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
// **** 0xf3: set l-line relay
|
||||
case 0xf3:
|
||||
{
|
||||
#ifdef PANDA
|
||||
if (safety_relay_hook()) {
|
||||
set_lline_output(setup->b.wValue.w == 1);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
puts("NO HANDLER ");
|
||||
puth(setup->b.bRequest);
|
||||
@@ -471,7 +457,6 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, int hardwired) {
|
||||
return resp_len;
|
||||
}
|
||||
|
||||
#ifdef PANDA
|
||||
int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) {
|
||||
// data[0] = endpoint
|
||||
// data[2] = length
|
||||
@@ -499,12 +484,6 @@ int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) {
|
||||
return resp_len;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { return 0; };
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// ***************************** main code *****************************
|
||||
|
||||
@@ -514,7 +493,99 @@ void __initialize_hardware_early() {
|
||||
|
||||
void __attribute__ ((noinline)) enable_fpu() {
|
||||
// enable the FPU
|
||||
SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2));
|
||||
SCB->CPACR |= ((3UL << (10 * 2)) | (3UL << (11 * 2)));
|
||||
}
|
||||
|
||||
uint64_t tcnt = 0;
|
||||
uint64_t marker = 0;
|
||||
|
||||
// called once per second
|
||||
void TIM3_IRQHandler() {
|
||||
#define CURRENT_THRESHOLD 0xF00
|
||||
#define CLICKS 5 // 5 seconds to switch modes
|
||||
|
||||
if (TIM3->SR != 0) {
|
||||
can_live = pending_can_live;
|
||||
|
||||
//puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n");
|
||||
|
||||
uint32_t current = adc_get(ADCCHAN_CURRENT);
|
||||
|
||||
switch (usb_power_mode) {
|
||||
case USB_POWER_CLIENT:
|
||||
if ((tcnt-marker) >= CLICKS) {
|
||||
if (!is_enumerated) {
|
||||
puts("USBP: didn't enumerate, switching to CDP mode\n");
|
||||
// switch to CDP
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
marker = tcnt;
|
||||
}
|
||||
}
|
||||
// keep resetting the timer if it's enumerated
|
||||
if (is_enumerated) {
|
||||
marker = tcnt;
|
||||
}
|
||||
break;
|
||||
case USB_POWER_CDP:
|
||||
// On the EON, if we get into CDP mode we stay here. No need to go to DCP.
|
||||
#ifndef EON
|
||||
// been CLICKS clicks since we switched to CDP
|
||||
if ((tcnt-marker) >= CLICKS) {
|
||||
// measure current draw, if positive and no enumeration, switch to DCP
|
||||
if (!is_enumerated && (current < CURRENT_THRESHOLD)) {
|
||||
puts("USBP: no enumeration with current draw, switching to DCP mode\n");
|
||||
set_usb_power_mode(USB_POWER_DCP);
|
||||
marker = tcnt;
|
||||
}
|
||||
}
|
||||
// keep resetting the timer if there's no current draw in CDP
|
||||
if (current >= CURRENT_THRESHOLD) {
|
||||
marker = tcnt;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case USB_POWER_DCP:
|
||||
// been at least CLICKS clicks since we switched to DCP
|
||||
if ((tcnt-marker) >= CLICKS) {
|
||||
// if no current draw, switch back to CDP
|
||||
if (current >= CURRENT_THRESHOLD) {
|
||||
puts("USBP: no current draw, switching back to CDP mode\n");
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
marker = tcnt;
|
||||
}
|
||||
}
|
||||
// keep resetting the timer if there's current draw in DCP
|
||||
if (current < CURRENT_THRESHOLD) {
|
||||
marker = tcnt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// ~0x9a = 500 ma
|
||||
/*puth(current);
|
||||
puts("\n");*/
|
||||
|
||||
// reset this every 16th pass
|
||||
if ((tcnt&0xF) == 0) pending_can_live = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
puts("** blink ");
|
||||
puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" ");
|
||||
puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" ");
|
||||
puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n");
|
||||
#endif
|
||||
|
||||
// set green LED to be controls allowed
|
||||
set_led(LED_GREEN, controls_allowed);
|
||||
|
||||
// turn off the blue LED, turned on by CAN
|
||||
// unless we are in power saving mode
|
||||
set_led(LED_BLUE, (tcnt&1) && power_save_status == POWER_SAVE_STATUS_ENABLED);
|
||||
|
||||
// on to the next one
|
||||
tcnt += 1;
|
||||
}
|
||||
TIM3->SR = 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
@@ -531,21 +602,19 @@ int main() {
|
||||
|
||||
// detect the revision and init the GPIOs
|
||||
puts("config:\n");
|
||||
#ifdef PANDA
|
||||
puts(revision == PANDA_REV_C ? " panda rev c\n" : " panda rev a or b\n");
|
||||
#else
|
||||
puts(" legacy\n");
|
||||
#endif
|
||||
puts((revision == PANDA_REV_C) ? " panda rev c\n" : " panda rev a or b\n");
|
||||
puts(has_external_debug_serial ? " real serial\n" : " USB serial\n");
|
||||
puts(is_giant_panda ? " GIANTpanda detected\n" : " not GIANTpanda\n");
|
||||
puts(is_grey_panda ? " gray panda detected!\n" : " white panda\n");
|
||||
puts(is_entering_bootmode ? " ESP wants bootmode\n" : " no bootmode\n");
|
||||
|
||||
// non rev c panda are no longer supported
|
||||
while (revision != PANDA_REV_C);
|
||||
|
||||
gpio_init();
|
||||
|
||||
#ifdef PANDA
|
||||
// panda has an FPU, let's use it!
|
||||
enable_fpu();
|
||||
#endif
|
||||
|
||||
// enable main uart if it's connected
|
||||
if (has_external_debug_serial) {
|
||||
@@ -554,22 +623,18 @@ int main() {
|
||||
uart_init(USART2, 115200);
|
||||
}
|
||||
|
||||
#ifdef PANDA
|
||||
if (is_grey_panda) {
|
||||
uart_init(USART1, 9600);
|
||||
} else {
|
||||
// enable ESP uart
|
||||
uart_init(USART1, 115200);
|
||||
#ifdef EON
|
||||
set_esp_mode(ESP_DISABLED);
|
||||
#endif
|
||||
}
|
||||
|
||||
// enable LIN
|
||||
uart_init(UART5, 10400);
|
||||
UART5->CR2 |= USART_CR2_LINEN;
|
||||
uart_init(USART3, 10400);
|
||||
USART3->CR2 |= USART_CR2_LINEN;
|
||||
#endif
|
||||
|
||||
// init microsecond system timer
|
||||
// increments 1000000 times per second
|
||||
@@ -585,136 +650,65 @@ int main() {
|
||||
// default to silent mode to prevent issues with Ford
|
||||
// hardcode a specific safety mode if you want to force the panda to be in a specific mode
|
||||
safety_set_mode(SAFETY_NOOUTPUT, 0);
|
||||
#ifdef EON
|
||||
// if we're on an EON, it's fine for CAN to be live for fingerprinting
|
||||
can_silent = ALL_CAN_LIVE;
|
||||
#else
|
||||
can_silent = ALL_CAN_SILENT;
|
||||
#endif
|
||||
can_init_all();
|
||||
|
||||
adc_init();
|
||||
|
||||
#ifdef PANDA
|
||||
spi_init();
|
||||
|
||||
#ifdef EON
|
||||
// have to save power
|
||||
if (!is_grey_panda) {
|
||||
set_esp_mode(ESP_DISABLED);
|
||||
}
|
||||
// only enter power save after the first cycle
|
||||
/*if (is_gpio_started() == 0) {
|
||||
power_save_enable();
|
||||
}*/
|
||||
// interrupt on started line
|
||||
started_interrupt_init();
|
||||
#endif
|
||||
|
||||
// 48mhz / 65536 ~= 732 / 732 = 1
|
||||
timer_init(TIM3, 732);
|
||||
NVIC_EnableIRQ(TIM3_IRQn);
|
||||
|
||||
#ifdef DEBUG
|
||||
puts("DEBUG ENABLED\n");
|
||||
#endif
|
||||
|
||||
// set PWM
|
||||
fan_init();
|
||||
fan_set_speed(0);
|
||||
|
||||
puts("**** INTERRUPTS ON ****\n");
|
||||
|
||||
__enable_irq();
|
||||
|
||||
power_save_init();
|
||||
|
||||
// if the error interrupt is enabled to quickly when the CAN bus is active
|
||||
// something bad happens and you can't connect to the device over USB
|
||||
delay(10000000);
|
||||
CAN1->IER |= CAN_IER_ERRIE | CAN_IER_LECIE;
|
||||
|
||||
// LED should keep on blinking all the time
|
||||
uint64_t cnt = 0;
|
||||
|
||||
#ifdef PANDA
|
||||
uint64_t marker = 0;
|
||||
#define CURRENT_THRESHOLD 0xF00
|
||||
#define CLICKS 8
|
||||
#endif
|
||||
|
||||
for (cnt=0;;cnt++) {
|
||||
can_live = pending_can_live;
|
||||
if (power_save_status == POWER_SAVE_STATUS_DISABLED) {
|
||||
int div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4 : 1);
|
||||
|
||||
//puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n");
|
||||
|
||||
#ifdef PANDA
|
||||
int current = adc_get(ADCCHAN_CURRENT);
|
||||
|
||||
switch (usb_power_mode) {
|
||||
case USB_POWER_CLIENT:
|
||||
if ((cnt-marker) >= CLICKS) {
|
||||
if (!is_enumerated) {
|
||||
puts("USBP: didn't enumerate, switching to CDP mode\n");
|
||||
// switch to CDP
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
marker = cnt;
|
||||
}
|
||||
// useful for debugging, fade breaks = panda is overloaded
|
||||
for (int div_mode_loop = 0; div_mode_loop < div_mode; div_mode_loop++) {
|
||||
for (int fade = 0; fade < 1024; fade += 8) {
|
||||
for (int i = 0; i < (128/div_mode); i++) {
|
||||
set_led(LED_RED, 1);
|
||||
if (fade < 512) { delay(fade); } else { delay(1024-fade); }
|
||||
set_led(LED_RED, 0);
|
||||
if (fade < 512) { delay(512-fade); } else { delay(fade-512); }
|
||||
}
|
||||
// keep resetting the timer if it's enumerated
|
||||
if (is_enumerated) {
|
||||
marker = cnt;
|
||||
}
|
||||
break;
|
||||
case USB_POWER_CDP:
|
||||
#ifndef EON
|
||||
// been CLICKS clicks since we switched to CDP
|
||||
if ((cnt-marker) >= CLICKS) {
|
||||
// measure current draw, if positive and no enumeration, switch to DCP
|
||||
if (!is_enumerated && current < CURRENT_THRESHOLD) {
|
||||
puts("USBP: no enumeration with current draw, switching to DCP mode\n");
|
||||
set_usb_power_mode(USB_POWER_DCP);
|
||||
marker = cnt;
|
||||
}
|
||||
}
|
||||
// keep resetting the timer if there's no current draw in CDP
|
||||
if (current >= CURRENT_THRESHOLD) {
|
||||
marker = cnt;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case USB_POWER_DCP:
|
||||
// been at least CLICKS clicks since we switched to DCP
|
||||
if ((cnt-marker) >= CLICKS) {
|
||||
// if no current draw, switch back to CDP
|
||||
if (current >= CURRENT_THRESHOLD) {
|
||||
puts("USBP: no current draw, switching back to CDP mode\n");
|
||||
set_usb_power_mode(USB_POWER_CDP);
|
||||
marker = cnt;
|
||||
}
|
||||
}
|
||||
// keep resetting the timer if there's current draw in DCP
|
||||
if (current < CURRENT_THRESHOLD) {
|
||||
marker = cnt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// ~0x9a = 500 ma
|
||||
/*puth(current);
|
||||
puts("\n");*/
|
||||
#endif
|
||||
|
||||
// reset this every 16th pass
|
||||
if ((cnt&0xF) == 0) pending_can_live = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
puts("** blink ");
|
||||
puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" ");
|
||||
puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" ");
|
||||
puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n");
|
||||
#endif
|
||||
|
||||
// set green LED to be controls allowed
|
||||
set_led(LED_GREEN, controls_allowed);
|
||||
|
||||
// blink the red LED
|
||||
int div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4 : 1);
|
||||
|
||||
for (int div_mode_loop = 0; div_mode_loop < div_mode; div_mode_loop++) {
|
||||
for (int fade = 0; fade < 1024; fade += 8) {
|
||||
for (int i = 0; i < 128/div_mode; i++) {
|
||||
set_led(LED_RED, 0);
|
||||
if (fade < 512) { delay(512-fade); } else { delay(fade-512); }
|
||||
set_led(LED_RED, 1);
|
||||
if (fade < 512) { delay(fade); } else { delay(1024-fade); }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
__WFI();
|
||||
}
|
||||
|
||||
// turn off the blue LED, turned on by CAN
|
||||
#ifdef PANDA
|
||||
set_led(LED_BLUE, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
//#define DEBUG
|
||||
//#define CAN_LOOPBACK_MODE
|
||||
//#define USE_INTERNAL_OSC
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#include "drivers/drivers.h"
|
||||
#include "drivers/llcan.h"
|
||||
#include "drivers/llgpio.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define CUSTOM_CAN_INTERRUPTS
|
||||
|
||||
#include "libc.h"
|
||||
#include "safety.h"
|
||||
#include "drivers/clock.h"
|
||||
#include "drivers/adc.h"
|
||||
#include "drivers/uart.h"
|
||||
#include "drivers/dac.h"
|
||||
#include "drivers/can.h"
|
||||
#include "drivers/timer.h"
|
||||
|
||||
#include "gpio.h"
|
||||
#include "libc.h"
|
||||
|
||||
#define CAN CAN1
|
||||
|
||||
//#define PEDAL_USB
|
||||
|
||||
#ifdef PEDAL_USB
|
||||
#include "drivers/uart.h"
|
||||
#include "drivers/usb.h"
|
||||
#else
|
||||
// no serial either
|
||||
int puts(const char *a) { return 0; }
|
||||
void puth(unsigned int i) {}
|
||||
#endif
|
||||
|
||||
#define ENTER_BOOTLOADER_MAGIC 0xdeadbeef
|
||||
@@ -35,6 +32,8 @@ void __initialize_hardware_early() {
|
||||
|
||||
// ********************* serial debugging *********************
|
||||
|
||||
#ifdef PEDAL_USB
|
||||
|
||||
void debug_ring_callback(uart_ring *ring) {
|
||||
char rcv;
|
||||
while (getc(ring, &rcv)) {
|
||||
@@ -42,8 +41,6 @@ void debug_ring_callback(uart_ring *ring) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PEDAL_USB
|
||||
|
||||
int usb_cb_ep1_in(uint8_t *usbdata, int len, int hardwired) { return 0; }
|
||||
void usb_cb_ep2_out(uint8_t *usbdata, int len, int hardwired) {}
|
||||
void usb_cb_ep3_out(uint8_t *usbdata, int len, int hardwired) {}
|
||||
@@ -185,7 +182,7 @@ void CAN1_RX0_IRQHandler() {
|
||||
|
||||
void CAN1_SCE_IRQHandler() {
|
||||
state = FAULT_SCE;
|
||||
can_sce(CAN);
|
||||
llcan_clear_send(CAN);
|
||||
}
|
||||
|
||||
int pdl0 = 0, pdl1 = 0;
|
||||
@@ -256,8 +253,7 @@ void pedal() {
|
||||
dac_set(1, pdl1);
|
||||
}
|
||||
|
||||
// feed the watchdog
|
||||
IWDG->KR = 0xAAAA;
|
||||
watchdog_feed();
|
||||
}
|
||||
|
||||
int main() {
|
||||
@@ -278,24 +274,18 @@ int main() {
|
||||
adc_init();
|
||||
|
||||
// init can
|
||||
can_silent = ALL_CAN_LIVE;
|
||||
can_init(0);
|
||||
llcan_set_speed(CAN1, 5000, false, false);
|
||||
llcan_init(CAN1);
|
||||
|
||||
// 48mhz / 65536 ~= 732
|
||||
timer_init(TIM3, 15);
|
||||
NVIC_EnableIRQ(TIM3_IRQn);
|
||||
|
||||
// setup watchdog
|
||||
IWDG->KR = 0x5555;
|
||||
IWDG->PR = 0; // divider /4
|
||||
// 0 = 0.125 ms, let's have a 50ms watchdog
|
||||
IWDG->RLR = 400 - 1;
|
||||
IWDG->KR = 0xCCCC;
|
||||
watchdog_init();
|
||||
|
||||
puts("**** INTERRUPTS ON ****\n");
|
||||
__enable_irq();
|
||||
|
||||
|
||||
// main pedal loop
|
||||
while (1) {
|
||||
pedal();
|
||||
|
||||
@@ -1,157 +1,57 @@
|
||||
#define POWER_SAVE_STATUS_DISABLED 0
|
||||
//Moving to enabled, but can wakeup not yet enabled
|
||||
#define POWER_SAVE_STATUS_SWITCHING 1
|
||||
#define POWER_SAVE_STATUS_ENABLED 2
|
||||
#define POWER_SAVE_STATUS_ENABLED 1
|
||||
|
||||
volatile int power_save_status = POWER_SAVE_STATUS_DISABLED;
|
||||
int power_save_status = POWER_SAVE_STATUS_DISABLED;
|
||||
|
||||
void power_save_enable(void) {
|
||||
power_save_status = POWER_SAVE_STATUS_SWITCHING;
|
||||
puts("Saving power\n");
|
||||
//Turn off can transciever
|
||||
if (power_save_status == POWER_SAVE_STATUS_ENABLED) return;
|
||||
puts("enable power savings\n");
|
||||
|
||||
// turn off can
|
||||
set_can_enable(CAN1, 0);
|
||||
set_can_enable(CAN2, 0);
|
||||
#ifdef PANDA
|
||||
set_can_enable(CAN3, 0);
|
||||
#endif
|
||||
|
||||
//Turn off GMLAN
|
||||
// turn off GMLAN
|
||||
set_gpio_output(GPIOB, 14, 0);
|
||||
set_gpio_output(GPIOB, 15, 0);
|
||||
|
||||
#ifdef PANDA
|
||||
//Turn off LIN K
|
||||
if (revision == PANDA_REV_C) {
|
||||
set_gpio_output(GPIOB, 7, 0); // REV C
|
||||
} else {
|
||||
set_gpio_output(GPIOB, 4, 0); // REV AB
|
||||
}
|
||||
// LIN L
|
||||
// turn off LIN
|
||||
set_gpio_output(GPIOB, 7, 0);
|
||||
set_gpio_output(GPIOA, 14, 0);
|
||||
#endif
|
||||
|
||||
if (is_grey_panda) {
|
||||
char* UBLOX_SLEEP_MSG = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78";
|
||||
int len = 12;
|
||||
char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78";
|
||||
uart_ring *ur = get_ring_by_number(1);
|
||||
for (int i = 0; i < len; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i]));
|
||||
for (int i = 0; i < sizeof(UBLOX_SLEEP_MSG)-1; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i]));
|
||||
}
|
||||
|
||||
//Setup timer for can enable
|
||||
TIM6->PSC = 48-1; // tick on 1 us
|
||||
|
||||
TIM6->ARR = 12; // 12us
|
||||
// Enable, One-Pulse Mode, Only overflow interrupt
|
||||
TIM6->CR1 = TIM_CR1_CEN | TIM_CR1_OPM | TIM_CR1_URS;
|
||||
TIM6->EGR = TIM_EGR_UG;
|
||||
TIM6->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
void power_save_enable_can_wake(void) {
|
||||
// CAN Automatic Wake must be done a little while after the sleep
|
||||
// On some cars turning off the can transciver can trigger the wakeup
|
||||
power_save_status = POWER_SAVE_STATUS_ENABLED;
|
||||
puts("Turning can off\n");
|
||||
CAN1->MCR |= CAN_MCR_SLEEP;
|
||||
CAN1->MCR |= CAN_MCR_AWUM;
|
||||
|
||||
CAN2->MCR |= CAN_MCR_SLEEP;
|
||||
CAN2->MCR |= CAN_MCR_AWUM;
|
||||
#ifdef PANDA
|
||||
CAN3->MCR |= CAN_MCR_SLEEP;
|
||||
CAN3->MCR |= CAN_MCR_AWUM;
|
||||
#endif
|
||||
|
||||
//set timer back
|
||||
TIM6->PSC = 48000-1; // tick on 1 ms
|
||||
TIM6->ARR = 10000; // 10s
|
||||
// Enable, One-Pulse Mode, Only overflow interrupt
|
||||
TIM6->CR1 = TIM_CR1_OPM | TIM_CR1_URS;
|
||||
TIM6->EGR = TIM_EGR_UG;
|
||||
}
|
||||
|
||||
void power_save_disable(void) {
|
||||
power_save_status = POWER_SAVE_STATUS_DISABLED;
|
||||
puts("not Saving power\n");
|
||||
TIM6->CR1 |= TIM_CR1_CEN; //Restart timer
|
||||
TIM6->CNT = 0;
|
||||
if (power_save_status == POWER_SAVE_STATUS_DISABLED) return;
|
||||
puts("disable power savings\n");
|
||||
|
||||
//Turn on can
|
||||
// turn on can
|
||||
set_can_enable(CAN1, 1);
|
||||
set_can_enable(CAN2, 1);
|
||||
|
||||
#ifdef PANDA
|
||||
set_can_enable(CAN3, 1);
|
||||
#endif
|
||||
|
||||
//Turn on GMLAN
|
||||
// turn on GMLAN
|
||||
set_gpio_output(GPIOB, 14, 1);
|
||||
set_gpio_output(GPIOB, 15, 1);
|
||||
|
||||
#ifdef PANDA
|
||||
//Turn on LIN K
|
||||
if (revision == PANDA_REV_C) {
|
||||
set_gpio_output(GPIOB, 7, 1); // REV C
|
||||
} else {
|
||||
set_gpio_output(GPIOB, 4, 1); // REV AB
|
||||
}
|
||||
// LIN L
|
||||
// turn on LIN
|
||||
set_gpio_output(GPIOB, 7, 1);
|
||||
set_gpio_output(GPIOA, 14, 1);
|
||||
#endif
|
||||
|
||||
if (is_grey_panda) {
|
||||
char* UBLOX_WAKE_MSG = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a";
|
||||
int len = 12;
|
||||
char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a";
|
||||
uart_ring *ur = get_ring_by_number(1);
|
||||
for (int i = 0; i < len; i++) while (!putc(ur, UBLOX_WAKE_MSG[i]));
|
||||
for (int i = 0; i < sizeof(UBLOX_WAKE_MSG)-1; i++) while (!putc(ur, UBLOX_WAKE_MSG[i]));
|
||||
}
|
||||
|
||||
//set timer back
|
||||
TIM6->PSC = 48000-1; // tick on 1 ms
|
||||
TIM6->ARR = 10000; // 10s
|
||||
// Enable, One-Pulse Mode, Only overflow interrupt
|
||||
TIM6->CR1 = TIM_CR1_CEN | TIM_CR1_OPM | TIM_CR1_URS;
|
||||
TIM6->EGR = TIM_EGR_UG;
|
||||
TIM6->CR1 |= TIM_CR1_CEN;
|
||||
power_save_status = POWER_SAVE_STATUS_DISABLED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Reset timer when activity
|
||||
void power_save_reset_timer() {
|
||||
TIM6->CNT = 0;
|
||||
if (power_save_status != POWER_SAVE_STATUS_DISABLED){
|
||||
power_save_disable();
|
||||
}
|
||||
}
|
||||
|
||||
void power_save_init(void) {
|
||||
puts("Saving power init\n");
|
||||
TIM6->PSC = 48000-1; // tick on 1 ms
|
||||
|
||||
|
||||
TIM6->ARR = 10000; // 10s
|
||||
// Enable, One-Pulse Mode, Only overflow interrupt
|
||||
TIM6->CR1 = TIM_CR1_CEN | TIM_CR1_OPM | TIM_CR1_URS;
|
||||
TIM6->EGR = TIM_EGR_UG;
|
||||
NVIC_EnableIRQ(TIM6_DAC_IRQn);
|
||||
puts("Saving power init done\n");
|
||||
TIM6->DIER = TIM_DIER_UIE;
|
||||
TIM6->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
void TIM6_DAC_IRQHandler(void) {
|
||||
//Timeout switch to power saving mode.
|
||||
if (TIM6->SR & TIM_SR_UIF) {
|
||||
TIM6->SR = 0;
|
||||
#ifdef EON
|
||||
if (power_save_status == POWER_SAVE_STATUS_DISABLED) {
|
||||
power_save_enable();
|
||||
} else if (power_save_status == POWER_SAVE_STATUS_SWITCHING) {
|
||||
power_save_enable_can_wake();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
TIM6->CR1 |= TIM_CR1_CEN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@ struct sample_t {
|
||||
int max;
|
||||
} sample_t_default = {{0}, 0, 0};
|
||||
|
||||
// no float support in STM32F2 micros (cortex-m3)
|
||||
#ifdef PANDA
|
||||
// safety code requires floats
|
||||
struct lookup_t {
|
||||
float x[3];
|
||||
float y[3];
|
||||
};
|
||||
#endif
|
||||
|
||||
void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
@@ -27,21 +25,14 @@ int driver_limit_check(int val, int val_last, struct sample_t *val_driver,
|
||||
const int MAX, const int MAX_RATE_UP, const int MAX_RATE_DOWN,
|
||||
const int MAX_ALLOWANCE, const int DRIVER_FACTOR);
|
||||
int rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA);
|
||||
#ifdef PANDA
|
||||
float interpolate(struct lookup_t xy, float x);
|
||||
|
||||
void lline_relay_init (void);
|
||||
void lline_relay_release (void);
|
||||
void set_lline_output(int to_set);
|
||||
#endif
|
||||
|
||||
typedef void (*safety_hook_init)(int16_t param);
|
||||
typedef void (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push);
|
||||
typedef int (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send);
|
||||
typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len);
|
||||
typedef int (*ign_hook)();
|
||||
typedef int (*fwd_hook)(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd);
|
||||
typedef int (*relay_hook)();
|
||||
|
||||
typedef struct {
|
||||
safety_hook_init init;
|
||||
@@ -50,21 +41,23 @@ typedef struct {
|
||||
tx_hook tx;
|
||||
tx_lin_hook tx_lin;
|
||||
fwd_hook fwd;
|
||||
relay_hook relay;
|
||||
} safety_hooks;
|
||||
|
||||
// This can be set by the safety hooks.
|
||||
int controls_allowed = 0;
|
||||
int gas_interceptor_detected = 0;
|
||||
int gas_interceptor_prev = 0;
|
||||
|
||||
// This is set by USB command 0xdf
|
||||
int long_controls_allowed = 1;
|
||||
|
||||
// Include the actual safety policies.
|
||||
#include "safety/safety_defaults.h"
|
||||
#include "safety/safety_honda.h"
|
||||
#include "safety/safety_toyota.h"
|
||||
#ifdef PANDA
|
||||
#include "safety/safety_toyota_ipas.h"
|
||||
#include "safety/safety_tesla.h"
|
||||
#include "safety/safety_gm_ascm.h"
|
||||
#endif
|
||||
#include "safety/safety_gm.h"
|
||||
#include "safety/safety_ford.h"
|
||||
#include "safety/safety_cadillac.h"
|
||||
@@ -97,10 +90,6 @@ int safety_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return current_hooks->fwd(bus_num, to_fwd);
|
||||
}
|
||||
|
||||
int safety_relay_hook(void) {
|
||||
return current_hooks->relay();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
uint16_t id;
|
||||
const safety_hooks *hooks;
|
||||
@@ -119,7 +108,6 @@ typedef struct {
|
||||
#define SAFETY_SUBARU 10
|
||||
#define SAFETY_GM_ASCM 0x1334
|
||||
#define SAFETY_TOYOTA_IPAS 0x1335
|
||||
#define SAFETY_TOYOTA_NOLIMITS 0x1336
|
||||
#define SAFETY_ALLOUTPUT 0x1337
|
||||
#define SAFETY_ELM327 0xE327
|
||||
|
||||
@@ -134,12 +122,9 @@ const safety_hook_config safety_hook_registry[] = {
|
||||
{SAFETY_HYUNDAI, &hyundai_hooks},
|
||||
{SAFETY_CHRYSLER, &chrysler_hooks},
|
||||
{SAFETY_SUBARU, &subaru_hooks},
|
||||
{SAFETY_TOYOTA_NOLIMITS, &toyota_nolimits_hooks},
|
||||
#ifdef PANDA
|
||||
{SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks},
|
||||
{SAFETY_GM_ASCM, &gm_ascm_hooks},
|
||||
{SAFETY_TESLA, &tesla_hooks},
|
||||
#endif
|
||||
{SAFETY_ALLOUTPUT, &alloutput_hooks},
|
||||
{SAFETY_ELM327, &elm327_hooks},
|
||||
};
|
||||
@@ -239,7 +224,6 @@ int rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA) {
|
||||
}
|
||||
|
||||
|
||||
#ifdef PANDA
|
||||
// interp function that holds extreme values
|
||||
float interpolate(struct lookup_t xy, float x) {
|
||||
int size = sizeof(xy.x) / sizeof(xy.x[0]);
|
||||
@@ -264,4 +248,3 @@ float interpolate(struct lookup_t xy, float x) {
|
||||
return xy.y[size - 1];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -115,9 +115,6 @@ static int cadillac_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
||||
static void cadillac_init(int16_t param) {
|
||||
controls_allowed = 0;
|
||||
cadillac_ign = 0;
|
||||
#ifdef PANDA
|
||||
lline_relay_release();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int cadillac_ign_hook() {
|
||||
@@ -131,5 +128,4 @@ const safety_hooks cadillac_hooks = {
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = cadillac_ign_hook,
|
||||
.fwd = alloutput_fwd_hook,
|
||||
.relay = nooutput_relay_hook,
|
||||
};
|
||||
|
||||
@@ -127,9 +127,6 @@ static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
||||
|
||||
static void chrysler_init(int16_t param) {
|
||||
chrysler_camera_detected = 0;
|
||||
#ifdef PANDA
|
||||
lline_relay_release();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int chrysler_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
@@ -153,5 +150,4 @@ const safety_hooks chrysler_hooks = {
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = chrysler_fwd_hook,
|
||||
.relay = nooutput_relay_hook,
|
||||
};
|
||||
|
||||
@@ -8,9 +8,6 @@ int default_ign_hook() {
|
||||
|
||||
static void nooutput_init(int16_t param) {
|
||||
controls_allowed = 0;
|
||||
#ifdef PANDA
|
||||
lline_relay_release();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
||||
@@ -25,10 +22,6 @@ static int nooutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int nooutput_relay_hook(int to_set) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const safety_hooks nooutput_hooks = {
|
||||
.init = nooutput_init,
|
||||
.rx = default_rx_hook,
|
||||
@@ -36,16 +29,12 @@ const safety_hooks nooutput_hooks = {
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.relay = nooutput_relay_hook,
|
||||
};
|
||||
|
||||
// *** all output safety mode ***
|
||||
|
||||
static void alloutput_init(int16_t param) {
|
||||
controls_allowed = 1;
|
||||
#ifdef PANDA
|
||||
lline_relay_release();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
||||
@@ -60,10 +49,6 @@ static int alloutput_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int alloutput_relay_hook(int to_set) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const safety_hooks alloutput_hooks = {
|
||||
.init = alloutput_init,
|
||||
.rx = default_rx_hook,
|
||||
@@ -71,5 +56,4 @@ const safety_hooks alloutput_hooks = {
|
||||
.tx_lin = alloutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = alloutput_fwd_hook,
|
||||
.relay = alloutput_relay_hook,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
static void elm327_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {}
|
||||
|
||||
static int elm327_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
|
||||
//All ELM traffic must appear on CAN0
|
||||
if(((to_send->RDTR >> 4) & 0xf) != 0) return 0;
|
||||
@@ -27,20 +25,11 @@ static int elm327_tx_lin_hook(int lin_num, uint8_t *data, int len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void elm327_init(int16_t param) {
|
||||
controls_allowed = 1;
|
||||
}
|
||||
|
||||
static int elm327_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const safety_hooks elm327_hooks = {
|
||||
.init = elm327_init,
|
||||
.rx = elm327_rx_hook,
|
||||
.init = nooutput_init,
|
||||
.rx = default_rx_hook,
|
||||
.tx = elm327_tx_hook,
|
||||
.tx_lin = elm327_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = elm327_fwd_hook,
|
||||
.relay = nooutput_relay_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
};
|
||||
|
||||
@@ -90,5 +90,4 @@ const safety_hooks ford_hooks = {
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = nooutput_fwd_hook,
|
||||
.relay = nooutput_relay_hook,
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user