Skip to content

Commit 23bbf52

Browse files
author
Vehicle Researcher
committed
Squashed 'cereal/' changes from 12aad06..286b7e5
286b7e5 capitalize docker command 0adfc7e add canErrorPersistent event c8be73d use github url instead of gitlab mirror 8e2d212 add pre-commit static analysis (emmertex#48) f27222f add gpsOK flag to liveLocationKalman 4bb1eb8 submaster always conflates 30838d4 C++ implementation of SubMaster and PubMaster (emmertex#42) c1a6d75 Fix potential segfault in MSGQPubSocket::connect (emmertex#45) 67fae6a Use ZMQ on MacOS (emmertex#46) 01cdf83 add default values for backwards compat c96381b add OK flags to locationd output d589d5e add white panda deprecation events 856c981 mark unused car events as deprecated 4f68db8 remove unnecessary new event type 9073b9b Library cleanup (emmertex#43) 7a786d9 move remaining alerts to car events d6f10a4 add alert event type git-subtree-dir: cereal git-subtree-split: 286b7e5
1 parent 5bfae8d commit 23bbf52

File tree

16 files changed

+282
-56
lines changed

16 files changed

+282
-56
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- uses: actions/checkout@v2
1212
- name: Build docker image
1313
run: docker build -t cereal .
14+
- name: Static analysis
15+
run: |
16+
docker run cereal bash -c "git init && git add -A && pre-commit run --all"
1417
- name: Unit Tests
1518
run: |
1619
docker run cereal bash -c "scons --test --asan -j$(nproc) && messaging/test_runner"
@@ -20,4 +23,3 @@ jobs:
2023
- name: Test MSGQ
2124
run: |
2225
docker run cereal bash -c "MSGQ=1 python -m unittest discover ."
23-

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ libmessaging_shared.*
1111
services.h
1212
.sconsign.dblite
1313
libcereal_shared.*
14-
14+
.mypy_cache/

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: master
4+
hooks:
5+
- id: check-ast
6+
- id: check-json
7+
- id: check-xml
8+
- id: check-yaml
9+
- repo: https://github.com/pre-commit/mirrors-mypy
10+
rev: master
11+
hooks:
12+
- id: mypy
13+
- repo: https://github.com/PyCQA/flake8
14+
rev: master
15+
hooks:
16+
- id: flake8
17+
args:
18+
- --select=F
19+
- repo: local
20+
hooks:
21+
- id: pylint
22+
name: pylint
23+
entry: pylint
24+
language: system
25+
types: [python]
26+
args:
27+
- --disable=R,C,W

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
from ubuntu:16.04
1+
FROM ubuntu:16.04
22

3-
RUN apt-get update && apt-get install -y libzmq3-dev clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
3+
RUN apt-get update && apt-get install -y libzmq3-dev capnproto libcapnp-dev clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
44

55
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
66
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
77
RUN pyenv install 3.7.3
88
RUN pyenv global 3.7.3
99
RUN pyenv rehash
10-
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4
10+
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4 pre-commit==2.4.0 pylint==2.5.2
1111

1212
WORKDIR /project/cereal
13-
COPY install_capnp.sh .
14-
RUN ./install_capnp.sh
1513

1614
ENV PYTHONPATH=/project
1715

1816
COPY . .
17+
RUN rm -rf .git
1918
RUN scons -c && scons -j$(nproc)

SConscript

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ if shutil.which('capnpc-java'):
2020
cereal_objects = env.SharedObject([
2121
'gen/cpp/car.capnp.c++',
2222
'gen/cpp/log.capnp.c++',
23+
'messaging/socketmaster.cc',
2324
])
2425

2526
env.Library('cereal', cereal_objects)
@@ -43,8 +44,10 @@ Depends('messaging/impl_zmq.cc', services_h)
4344

4445
# note, this rebuilds the deps shared, zmq is statically linked to make APK happy
4546
# TODO: get APK to load system zmq to remove the static link
46-
shared_lib_shared_lib = [zmq, 'm', 'stdc++'] + ["gnustl_shared"] if arch == "aarch64" else [zmq]
47-
env.SharedLibrary('messaging_shared', messaging_objects, LIBS=shared_lib_shared_lib)
47+
if arch == "aarch64":
48+
zmq_static = FindFile("libzmq.a", "/usr/lib")
49+
shared_lib_shared_lib = [zmq_static, 'm', 'stdc++', "gnustl_shared"]
50+
env.SharedLibrary('messaging_shared', messaging_objects, LIBS=shared_lib_shared_lib)
4851

4952
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq'])
5053
Depends('messaging/bridge.cc', services_h)

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: skip-file
12
import os
23
import capnp
34

car.capnp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ struct CarEvent @0x9b1657f34caf3ad3 {
1313
name @0 :EventName;
1414
enable @1 :Bool;
1515
noEntry @2 :Bool;
16-
warning @3 :Bool;
16+
warning @3 :Bool; # alerts presented only when enabled or soft disabling
1717
userDisable @4 :Bool;
1818
softDisable @5 :Bool;
1919
immediateDisable @6 :Bool;
2020
preEnable @7 :Bool;
21-
permanent @8 :Bool;
21+
permanent @8 :Bool; # alerts presented regardless of openpilot state
2222

2323
enum EventName @0xbaa8c5d505f727de {
2424
# TODO: copy from error list
@@ -38,7 +38,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
3838
pedalPressed @13;
3939
cruiseDisabled @14;
4040
radarCanError @15;
41-
dataNeeded @16;
41+
dataNeededDEPRECATED @16;
4242
speedTooLow @17;
4343
outOfSpace @18;
4444
overheat @19;
@@ -55,23 +55,23 @@ struct CarEvent @0x9b1657f34caf3ad3 {
5555
manualRestart @30;
5656
lowSpeedLockout @31;
5757
plannerError @32;
58-
ipasOverride @33;
58+
ipasOverrideDEPRECATED @33;
5959
debugAlert @34;
6060
steerTempUnavailableMute @35;
6161
resumeRequired @36;
6262
preDriverDistracted @37;
6363
promptDriverDistracted @38;
6464
driverDistracted @39;
65-
geofence @40;
66-
driverMonitorOn @41;
67-
driverMonitorOff @42;
65+
geofenceDEPRECATED @40;
66+
driverMonitorOnDEPRECATED @41;
67+
driverMonitorOffDEPRECATED @42;
6868
preDriverUnresponsive @43;
6969
promptDriverUnresponsive @44;
7070
driverUnresponsive @45;
7171
belowSteerSpeed @46;
72-
calibrationProgress @47;
72+
calibrationProgressDEPRECATED @47;
7373
lowBattery @48;
74-
invalidGiraffeHonda @49;
74+
invalidGiraffeHondaDEPRECATED @49;
7575
vehicleModelInvalid @50;
7676
controlsFailed @51;
7777
sensorDataInvalid @52;
@@ -93,10 +93,19 @@ struct CarEvent @0x9b1657f34caf3ad3 {
9393
driverMonitorLowAcc @68;
9494
invalidLkasSetting @69;
9595
speedTooHigh @70;
96-
laneChangeBlocked @71;
96+
laneChangeBlockedDEPRECATED @71;
9797
relayMalfunction @72;
9898
gasPressed @73;
9999
stockFcw @74;
100+
startup @75;
101+
startupNoCar @76;
102+
startupNoControl @77;
103+
startupMaster @78;
104+
fcw @79;
105+
steerSaturated @80;
106+
whitePandaUnsupported @81;
107+
startupWhitePanda @82;
108+
canErrorPersistent @83;
100109
}
101110
}
102111

install_capnp.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,3 @@ CXXFLAGS="-fPIC" ./configure
1010

1111
make -j$(nproc)
1212
make install
13-
14-
# manually build binaries statically
15-
g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnp src/capnp/compiler/module-loader.o src/capnp/compiler/capnp.o ./.libs/libcapnpc.a ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread
16-
17-
g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnpc-c++ src/capnp/compiler/capnpc-c++.o ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread
18-
19-
g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnpc-capnp src/capnp/compiler/capnpc-capnp.o ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread
20-
21-
cp .libs/capnp /usr/local/bin/
22-
cp .libs/capnpc-c++ /usr/local/bin/
23-
cp .libs/capnpc-capnp /usr/local/bin/
24-
cp .libs/*.a /usr/local/lib
25-
26-
cd /tmp
27-
echo "Installing c-capnp"
28-
git clone https://github.com/commaai/c-capnproto.git
29-
cd c-capnproto
30-
git submodule update --init --recursive
31-
autoreconf -f -i -s
32-
CXXFLAGS="-fPIC" ./configure
33-
make -j$(nproc)
34-
make install
35-
36-
# manually build binaries statically
37-
gcc -fPIC -o .libs/capnpc-c compiler/capnpc-c.o compiler/schema.capnp.o compiler/str.o ./.libs/libcapnp_c.a
38-
39-
cp .libs/capnpc-c /usr/local/bin/
40-
cp .libs/*.a /usr/local/lib

log.capnp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,9 @@ struct LiveLocationKalman {
855855
gpsTimeOfWeek @14 :Float64;
856856
status @15 :Status;
857857
unixTimestampMillis @16 :Int64;
858+
inputsOK @17 :Bool = true;
859+
posenetOK @18 :Bool = true;
860+
gpsOK @19 :Bool = true;
858861

859862
enum Status {
860863
uninitialized @0;

messaging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self, services, ignore_alive=None, addr="127.0.0.1"):
155155

156156
try:
157157
data = new_message(s)
158-
except capnp.lib.capnp.KjException:
158+
except capnp.lib.capnp.KjException: # pylint: disable=c-extension-no-member
159159
# lists
160160
data = new_message(s, 0)
161161

0 commit comments

Comments
 (0)